in reply to Re^5: Reg Exp to handle variations in the matched pattern
in thread Reg Exp to handle variations in the matched pattern

Thanks for this. This is a great help. Do you happen to have an example of code that you would use to tag a text file? I like the idea of tag with HTML/XML style tags, but I don't have time to build something, so maybe I'll use Perl to convert this text file to a delimited file and use a db to extract text.
  • Comment on Re^6: Reg Exp to handle variations in the matched pattern

Replies are listed 'Best First'.
Re^7: Reg Exp to handle variations in the matched pattern
by bitingduck (Deacon) on Feb 23, 2012 at 17:03 UTC
    That pretty much was code to tag a text file:
    open(MYINPUTFILE, "<sdnew02.txt"); while (<MYINPUTFILE>){ $_ =~ s/(\s-)$/\<tag\>$1<\/tag\>/g; $_ =~ s/(:)$/\<tag\>$1<\/tag\>/g; print $_,""; }
    All I've done is wrap tags around the found object and stick in a global modifier. replace the search regex and tags with whatever you want to tag. It won't quite work around your line breaks, but you can start from there.