regex - How do i match a specific input within a string in Java? -


i using regex in line of code:

if (line.matches("^.*\b(" + incomingmachineip + ")\b.*$")) 

so, assume following inputs:

incomingmachineip = "10.10.10.10"  line = "abcde=10.10.10.10abcedf" 

i want if condition return true, i'm trying regex above false still returned though value of incomingmachineip found in string (line)

any how resolve appreciated.

you need escape backslash 1 more times , need remove second \b or replace \b because there isn't word boundary exists between last 0 , letter a

if(line.matches(".*\\b" + pattern.quote(incomingmachineip) + ".*")) 

since you're using matches method, won't require anchors.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -