Ask a Question related to PERL Miscellaneous, Design and Development.
-
joeri #1
undo the (?i)
Hi all,
I have an RE where I use the (?i) somewhere, but I want to undo that effect
further on in the RE.
Here's an example:
$var="(?i)(forty|fifty)";
$input = "Forty-ninth ST";
if ($input =~ /$var(\-ninth)\s[S|s]t/) {
print "$&\n";
}
Because the $var contains the (?i), it matches the rest of the RE
case-insensitively, but I want
to match everything after the $var case-sensitively. Can I escape the ($i)
or set the scope of it?
Thanks,
J
joeri Guest
-
undo highlighting in AA 5.0
hi all, received a pdf from a client, that received it from his client, with yellow highlighting in certain sections. he would like to "undo" that... -
ID CS2: can't undo
Help! We have a file open in indesign that has not been saved in a while, a large amount of work has just been deleted but we cannot 'undo'. Apple-Z... -
Undo Levels?
It seems there is only one level of "undo" in Director MX 2004 (mac). I've searched the preferences and help files and cannot seem to find any... -
undo bitmap?
Hi, is there any way to "undo" an image after I flattened/saved it to bitmap? (undo CNTL + Z not an option - too late for that) Thanks. John -
Undo in TextBox
Hi, If a user enters a wrong value (which depends on some properties of it's container control) in one of my dynamicly made TextBoxes I want to... -
Tassilo v. Parseval #2
Re: undo the (?i)
Also sprach joeri:
You can again turn it off at some point:> I have an RE where I use the (?i) somewhere, but I want to undo that effect
> further on in the RE.
> Here's an example:
>
> $var="(?i)(forty|fifty)";
> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
> print "$&\n";
> }
>
> Because the $var contains the (?i), it matches the rest of the RE
> case-insensitively, but I want
> to match everything after the $var case-sensitively. Can I escape the ($i)
> or set the scope of it?
$input =~ /$var(?-i)(-ninth)\s[S|s]t/;
So, -i will prevent case-insensitive matching for the patterns right of
it.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest
-
Tassilo v. Parseval #3
Re: undo the (?i)
Also sprach joeri:
> Tassilo v. Parseval wrote:
>>>>> > I have an RE where I use the (?i) somewhere, but I want to undo
>> > that effect further on in the RE.
>> > Here's an example:
>> >
>> > $var="(?i)(forty|fifty)";
>> > $input = "Forty-ninth ST";
>> > if ($input =~ /$var(\-ninth)\s[S|s]t/) {
>> > print "$&\n";
>> > }
>> >
>> > Because the $var contains the (?i), it matches the rest of the RE
>> > case-insensitively, but I want to match everything after the $var
>> > case-sensitively. Can I escape the ($i) or set the scope of it?
>> You can again turn it off at some point:
>>
>> $input =~ /$var(?-i)(-ninth)\s[S|s]t/;
>>
>> So, -i will prevent case-insensitive matching for the patterns right of
>> it.You'll find it in perlre.pod under "Extended patterns":> Thanks! I couldn't find it in the docs or google.
"(?imsx-imsx)"
One or more embedded pattern-match modifiers, to be turned on
(or turned off, if preceded by "-") for the remainder of the
pattern or the remainder of the enclosing pattern group (if
any). [...]
It can indeed be easily overlooked.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest
-
joeri #4
Re: undo the (?i)
Tassilo v. Parseval wrote:
on> Also sprach joeri:
>>> > Tassilo v. Parseval wrote:
> >> >> > I have an RE where I use the (?i) somewhere, but I want to undo
> >> > that effect further on in the RE.
> >> > Here's an example:
> >> >
> >> > $var="(?i)(forty|fifty)";
> >> > $input = "Forty-ninth ST";
> >> > if ($input =~ /$var(\-ninth)\s[S|s]t/) {
> >> > print "$&\n";
> >> > }
> >> >
> >> > Because the $var contains the (?i), it matches the rest of the RE
> >> > case-insensitively, but I want to match everything after the $var
> >> > case-sensitively. Can I escape the ($i) or set the scope of it?
> >>
> >> You can again turn it off at some point:
> >>
> >> $input =~ /$var(?-i)(-ninth)\s[S|s]t/;
> >>
> >> So, -i will prevent case-insensitive matching for the patterns right of
> >> it.>> > Thanks! I couldn't find it in the docs or google.
> You'll find it in perlre.pod under "Extended patterns":
>
> "(?imsx-imsx)"
> One or more embedded pattern-match modifiers, to be turnedHere's what my 5.6 docs say. It is indeed there, but I overlooked it...> (or turned off, if preceded by "-") for the remainder of the
> pattern or the remainder of the enclosing pattern group (if
> any). [...]
>
> It can indeed be easily overlooked.
>
(?imsx-imsx)
One or more embedded pattern-match modifiers. This is particularly useful
for dynamic patterns, such as those read in from a configuration file, read
in as an argument, are specified in a table somewhere, etc. Consider the
case that some of which want to be case sensitive and some do not. The case
insensitive ones need to include merely (?i) at the front of the pattern.
For example:
$pattern = "foobar";
if ( /$pattern/i ) { } # more flexible: $pattern = "(?i)foobar";
if ( /$pattern/ ) { }Letters after a - turn those modifiers off.
J
joeri Guest
-
Brian McCauley #5
Re: undo the (?i)
"joeri" <jvandervloet@hotmail.com> writes:
> $var="(?i)(forty|fifty)";
> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
> print "$&\n";
> }/(?:$var)(\-ninth)\s[S|s]t/> Can I escape the ($i) or set the scope of it?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
Brian McCauley Guest
-
John W. Krahn #6
Re: undo the (?i)
joeri wrote:
Change that to:>
> I have an RE where I use the (?i) somewhere, but I want to undo that effect
> further on in the RE.
> Here's an example:
>
> $var="(?i)(forty|fifty)";
$var = '(?i:forty|fifty)';
Which will limit the effects of case insensitivity to the enclosing
parenthesis.
^^^^^> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
Your character class is trying to match a 'S' or a '|' or a 's'. Do you
really want to match a vertical bar here? The hyphen is not special in
regular expressions, there is no need to backslash it.
> print "$&\n";
> }
John
--
use Perl;
program
fulfillment
John W. Krahn Guest



Reply With Quote

