• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with regular expression: Match decimal or word  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to everyone. I am currently experiencing a problem using regular expressions. I am new to this topic, which is perhaps
one reason I am experiencing difficulties. In my application, I am reading strings and for every string I retrieve content located
between the following characters: '>' and '<', such as: >xxxxx<. Initially I only wished to retrieve information that was in decimal
format or percentage format. I used the following:

String regEx = ">([-]?)[0-9]+\\.[0-9][0-9]([%]?)<";
(I wish to keep the surrounding >< .

Everything worked fine until this point. The problem I am now having is that I wish to retrieve the content between the >< characters if they
are in decimal/percentage format or if the word EVEN is written. I tried the following:

String regEx = ">([-]?)[0-9]+\\.[0-9][0-9]([%]?)< | ^(>EVEN< $";

but when I ran my application, all values were now null.
Could someone please help me. Thank you in advance for any help.
 
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!