Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: More Regexp Confusion

by AltBlue (Chaplain)
on Feb 01, 2007 at 22:15 UTC ( [id://597843]=note: print w/replies, xml ) Need Help??

in reply to More Regexp Confusion

What do you mean by "xx"? A "constant" string? For example, if $foo = 'GOAT', you mean to match strings like:
If this assumption is correct, this is a possible way (yet quite inefficient) to handle it:
my @foo = split //, $foo; $foo = shift(@foo) . q{(.*?)} . join q{\2}, @foo; while ( my $line = <FH> ) { s/($foo)/$stuff1$1$stuff2/g; }

Replies are listed 'Best First'.
Re^2: More Regexp Confusion
by mdunnbass (Monk) on Feb 01, 2007 at 22:29 UTC
    Actually, it's not a constant string. I was trying to say in the OP that I didn't care what the 'xx' was, but I guess I didn't explain that very well.

    In reality, most likely, it'll take the form of possible HTML tags. I say possible, because there most likely will be none, but there might be some, and if they're there, they may be either opening or closing tags, or even tags with multiple attributes. I do know that any text will be lowercase. So, for instance, given $foo = 'GOAT', I want all of the following to match:

    asdfgGOATaewrjgn ererGOAskjgbrTslkgjnjng ccG<!-- comment on status of global geopolitical economics -->OAjgTsvs aGO<h3>i hate clowns</h3>ATbbb

    And in the last example, the output that I want would be:

    'a' . $stuff1 . 'GO<h3>i hate clowns</h3>AT' . $stuff2 . 'bbb'
    I hope that helps.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597843]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-06-17 20:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.