java - What is the regex for the finding the string with the pattern ALXXXXX in another string? -


i want find string of pattern alxxxxx inside string.

example want string al00123 in string data stage al00123

i have tried following in java.

pattern pattern = pattern.compile("al\\d\\d\\d\\d\\d"); matcher matcher = pattern.matcher(searchstring); boolean matches = matcher.matches(); 

this returns false. what wrong code?

i want achieve following

  1. determine if search string contains alxxxxx.
  2. retrieve value of alxxxxx.
  3. i want in java.

following various ways alxxxxx may occur in of following ways

  1. data stage_al00123
  2. data stage al00123
  3. data stage(al00123)
  4. data stage(_al00123)
  5. data stageal00123

finally

  1. the string begin al
  2. the string have 5 digits following al

using matcher#matches matches regex pattern against whole input string. want use find instead.

you can reduce regex al\\d{5}.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -