java Regex Question -


In Java - I need to search / validate an input string for a number or for a specific string. I

Must be one of them. For example - if I have this input line:

  cccccccc 123 vvvvvvvvvv jhdakfksah cccccccc abc vvvvvvnhj yroijpotpo cccdcdcd 234 vcbvbvbvbv lkjd dfdggf ccccbvff ABC jflkjlkjlj fgdgfg  

I need 123, ABC, 234, to find ABC

I can use regex to use the number: "\ d +" but to see any of them I How do I add them?

you | You can specify the options in regular expressions using the character:

 In your specific example, the string you want appears to be always the second word ("delimited by space"), so it Can be beneficial. To include this, include the place in regular expressions. Either use a capturing group to capture the part that you really want to remove:  
  "(\ d + | [ABC] +)"  < / Pre> 

(The quotation marks used to delimit I Regex). Or using a perspective:

  (? & Lt; =) (\ d + | [ABC] +)  

from the desired part Will match, but still need space for it.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -