Java regular expressions / regex -


i have following string:

$500 has been received username [rank]. 

i use following regex statement attempt amount paid (500) , username.

"^\\$(\\d+\\.?\\d*) has been received ([^.]+)\\.$" 

unfortunately extracting this:

"username [rank]" 

i have attempted modify instead of reading until '.' username variable read ' ', multiple back-slashes seem confusing me , unexpected results.

what regex 'code' need use extract balance , username? (the rank of no use me).

many thanks!

is kind of homework? reason ask this:

regex value until character

anyway - according site:

http://www.regexplanet.com/advanced/java/index.html

this shall work:

^\$(\d+\.?\d*) has been received (.*)\s\[(.*)\].$ 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -