0

I have a text :

Revenue: $12.9 billion Regex=====>Revenue\W+(\$*\s*\d+\s*(\.\s*\d+)*)\s*billion 

Now I want $12.9 in a specific group but by using \W+ it takes ": $" after revenue. So I want to write such regex that it will consider all nonalphanumeric character except "$"

How can I do that???

1
  • Revenue.\s.\d*.\d*\s\w+ Commented Mar 20, 2014 at 10:06

2 Answers 2

1

A character class like [^\w$] will match anything that is not a word character or $. Also, there's no need to have \s* twice together, or to have it appear after \W+ (or [^\w$]+) because the preceding character class will swallow up any whitespace characters anyway:

Revenue[^\w$]+(\d+\s*(\.\s*\d+))\s*billion 
Sign up to request clarification or add additional context in comments.

Comments

0
Revenue[^\w$]+(.\s*\d+\s*(\.\s*\d+))\s*billion 

use this,

the . will match the unmatched $

demo here : http://regex101.com/r/aQ8qP7

$12.9 is captured in the first group

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.