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
- determine if search string contains alxxxxx.
- retrieve value of alxxxxx.
- i want in java.
following various ways alxxxxx may occur in of following ways
- data stage_al00123
- data stage al00123
- data stage(al00123)
- data stage(_al00123)
- data stageal00123
finally
- the string begin al
- 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
Post a Comment