Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Using special characters in left part of a regex match?

by LanX (Chancellor)
on Feb 05, 2013 at 23:01 UTC ( #1017298=note: print w/replies, xml ) Need Help??

in reply to Using special characters in left part of a regex match?

> Is there a way to put special characters in the left part of the regular expression?

with special characters you mean the regex wildcards you're including for ... and the answer is no.

in short

$var[1] = "Gallia est omnis divisa in .+"; $var[5] = "Gallia est .+ tres"; $var[1] =~ $var[5] ;# false

what could maybe work is to successively strip common beginning and/or ending parts.

"Gallia est ..." is the smallest starting substring till an ellipsis.

Deleting it from both strings:

$var[1] = "omnis divisa in ..."; $var[5] = "... tres";

this configuration is always true.

such a strategy might work.

Cheers Rolf

Replies are listed 'Best First'.
Re^2: Using special characters in left part of a regex match?
by shamat (Acolyte) on Feb 06, 2013 at 16:56 UTC
    Thank you for the suggestion, I really appreciate it! I'll try your strategy, which I think may work well with syntactical variations as well.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017298]
[Corion]: It had been approved as a Perl Monks Discussion. It should now be approvable into SoPW
[choroba]: Approved
[LanX]: hmm aproval doesn't stick after move? Or was it a race condition
[Corion]: I think you need at least one reload after moving before you can approve in the correct section
[GotToBTru]: it was approved . but isnt now
[GotToBTru]: ah nevermind .. i was looking at one of 2
[GotToBTru]: SOPW version still shows approved by choroba

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2017-01-16 15:10 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.