CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Strange behavior with regex replacing

 



TheBlackNoodle
New User

Jun 18, 2008, 12:06 PM

Post #1 of 1 (1887 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:


Code
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)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives