match and regular expressions
As it's supposed to, this just matches the last capture of the bolded group, so, just -52.1 is returned. I can't think of an easy way around this, so I wondered if anyone else has one.
var r = /[mc]([+-]?\d+(\.\d+)?,?)+/i;
If not, I'll probably end up leaving the regular expressions and using normal string methods to parse it, but I'd really like to use regular expressions.
Why you use 'mc' insted of 'm' for matching letter 'm'.
I really say I did not clearly undestand whcic h data matched
2 matches are returned: -52.1 and .1
Can you be more specific in what should be returned?
Because I'm also matching for c! That's just a sample.
Originally Posted by Pprakash
@Fang, indeed I wasn't very clear. I want 12.6 and -52.1 without having to repeat myself in the regular expression.
will do what I want, but since I also want to be able to match a bezier curve which has 6 coordinates, I would rather not have to use things like this.
var r = /([+-]?[\d+\.?\d+]+)/g;
var arr ="m12.6-52.1".match(r);
That'll do fine. I'd rather test for the m or c in the same regexp all in one go, but what you have is great, thanks.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)