I need to extract numeric values from strings like “£17,000 – £35,000 dependent on experience”
([0-9]+k?[.,]?[0-9]+)
That string is just an example, i can have 17k 17.000 17 17,000, in every string there can be 0,1 or 2 numbers (not more than 2), they can be everywhere in the string, separated by anything else. I just need to extract them, put the first extracted in a place and the second in another.
I could come up with this, but it gives me two matches (don’t mind the k?[,.], it’s correct), in the $1 grouping. I need to have 17,000 in $1 and 35,000 in $2, how can i accomplish this? I can also manage to use 2 different regex
Using regex
With every opening round bracket you create a new capturing group. So to have a second capturing group
$2, you need to match the second number with another part of your regex that is within brackets and of course you need to match the part between the to numbers.See here on Regexr
But could be that Solr has regex functions that put all matches into an array, that would maybe be easier to use.