-1

I have a string with multiple delimiters, i.e. ,':|£. I want to extract only the number from the string, along with the currency symbol. I tried many possible ways but was unsuccessful. Could someone help me with this.

The entire string is given below. I want to extract only the currency, like £340,346

chartInfoValues(event,'Investment Activity Graph','','Year:|2014|Current:|£340,346|Recommended:|£340,346','aa709fd2','220','80')
  • 2
    did you try to use [regex](http://stackoverflow.com/questions/600733/using-java-to-find-substring-of-a-bigger-string-using-regular-expression)? – almeynman Apr 16 '15 at 11:00

2 Answers2

1

also I would recommend you to look at the StringTokenizer java class Taking an example from the documenation: "my name is khan"-splitting on the basis of whitespace

StringTokenizer st = new StringTokenizer("my name is khan"," ");  
     while (st.hasMoreTokens()) {  
         System.out.println(st.nextToken());  
     }  

Hope this helps to you.

eugene.polschikov
  • 7,254
  • 2
  • 31
  • 44
0

So what you want is the regex to use for String.split()? If so this works:

(£[0-9]*),[0-9]*

slighty tidier approach:

£(\d*,\d*)
Cathal
  • 1,318
  • 1
  • 12
  • 19