F
Fritz Bayer
Hello,
I have the problem that the regular expression (word1|word2|word3)? is
not being recalled when later being referenced using $1.
Here a very simple example:
$context = "This is a very simple sentence. Always, the second up to
the last word of this sentence should be captured!"
$content =~ s/(simple|easy|plain|simplitic)?.*Always(.*)captured!/
print($1 . "\n")/iesg;
Now, I would expect this to be printing out "simple" followed by ",
the second up to the last word of this sentence should be " to the
console.
However, this does not happen. I used $& to look at what gets matched
and it seems nothing at all.
If I take the question mark out - then the expresson matches, but the
problem is, that I also want the the following variation of the above
sentence to match:
"$context = "This is a very STUPID sentence. Always, the second up to
the last word of this sentence should be captured!"
The reason is, that I want to capture any expressoin which matches the
regular expression:
Always(.*)variations!
Now, if this regular expression is precedded by one of the words in
the list, then I would like to know about it and capture/print it out.
Do you know the a regular expression to achieve this?
Thanks,
Fritz
I have the problem that the regular expression (word1|word2|word3)? is
not being recalled when later being referenced using $1.
Here a very simple example:
$context = "This is a very simple sentence. Always, the second up to
the last word of this sentence should be captured!"
$content =~ s/(simple|easy|plain|simplitic)?.*Always(.*)captured!/
print($1 . "\n")/iesg;
Now, I would expect this to be printing out "simple" followed by ",
the second up to the last word of this sentence should be " to the
console.
However, this does not happen. I used $& to look at what gets matched
and it seems nothing at all.
If I take the question mark out - then the expresson matches, but the
problem is, that I also want the the following variation of the above
sentence to match:
"$context = "This is a very STUPID sentence. Always, the second up to
the last word of this sentence should be captured!"
The reason is, that I want to capture any expressoin which matches the
regular expression:
Always(.*)variations!
Now, if this regular expression is precedded by one of the words in
the list, then I would like to know about it and capture/print it out.
Do you know the a regular expression to achieve this?
Thanks,
Fritz