
TheBlackNoodle
New User
Jun 18, 2008, 12:06 PM
Post #1 of 1
(1377 views)
|
|
Strange behavior with regex replacing
|
Can't Post
|
|
Hey guys, I'm having a weird problem that doesn't make any sense to me. Here's the specific case:
regex: "(.*?y)\s(.*?)" format: "$1ing $2IN" input: "study stVdi:" output: "studying INstVdi:" The output is screwed up--no matter what I do, $2 is showing up at the end of the string. It's very much worth noting that I'm actually working in C++ using the Boost library with perl-style matching. But before I go and hassle the regex++ people, I want to make sure that I'm not doing something stupid. Is there anything wrong with my test case here that would cause this behavior? EDIT: Scratch that, I figured it out. It only took me three days. :P The second non-greedy match was capturing "", so I just had to remove the ?.
(This post was edited by TheBlackNoodle on Jun 18, 2008, 12:09 PM)
|