Question

I have the following string:

 <span class="pos">$2.472,38</span>

I would like to get 2472,38 (and eventually 2472.38)

I've been trying in regexpal, and found that [\d,.]+ seems to work, but due to the way the regex module of yahoo pipes work (replace ... with ..., I have to first select all the string

So I was thinking

replace .+([\d,.]+).+ with $1

But that's only giving me as result 8 (the last digit). So I guess something is not right the way I'm defining the capture group. any clue? Thanks in advance

you can find the pipe here http://pipes.yahoo.com/pipes/pipe.info?_id=06780ca250e5b107b7c1ef52455996ff

Was it helpful?

Solution

Your first subexpression .+ is being "greedy" (i.e. trying to match all it can while still allowing the whole expression to succeed), so it's matching everything up until the last digit. You need to "stop" before the start of the digits somehow based on your knowledge of what can precede the digits. If you know there is a dollar sign right before the digit and no dollar/digit combinations in the span element, you can simply add a \$ after the .+, as in .+\$([\d,.]+).+

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top