Sign in to follow this  
Followers 0
OJCIT

Regexp Match Data for StrRegExpReplace?

1 post in this topic

Is there an easy way to get the pre-match and post-match contents of a string? In Ruby, IIRC, you do $` or $', or use a MatchData object.

I think I need this because I want to replace a pattern that might occur several times in a string with a different substring for each occurrence. Specifically, I want to find all the numbers (\d+(\.\d*)?([eE]\d+)) and replace each one with a another number whose value depends on it, but StrRegExpReplace wants to replace all the matches with the same replacement string. I can set the count to one, but without knowing the offset of the last match, the next time I apply StrRegExpReplace, it'll match the new pattern So basically I need something like StringSplit that will split my string at the end of each match. Since there are a variable number of matches for each string I'm testing, I don't see how use the , \1, etc cleanly.

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0