#problem with regex

1 messages · Page 1 of 1 (latest)

plain gulch
#
import java.util.Arrays;

public class testing {
    public static void main(String[] args) {
        System.out.println("[email protected]".matches("\"\\w+@\\w+.(com|us|uk)\"i"));
    }
}

why this printing false?

quaint dustBOT
#

<@&987246399047479336> please have a look, thanks.

quaint dustBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

void plaza
plain gulch
#

so I can't add regex flags in java?

honest abyss
#

What's the I there for?

#

I doubt it should be there

plain gulch
#

case insensitive

honest abyss
#

Other than that everything seems fine

#

Shouldn't that be \\i then?

plain gulch
#

oh well mby, I was just copying the regex from https://regex101.com/ and whenever I paste it without any quotes it's error so I put the whole thing in quotes

regex101

Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

obsidian osprey
#

Pattern.compile("blabla", flags here)

#

consult the doc for details

obsidian osprey
plain gulch
#

oh I see, thanks!

honest abyss
#

So sometimes it causes confusion

obsidian osprey
#

its merely the underlying regex engine that changes

#

since they all work slightly different and have different feature sets

honest abyss
#

But if you copy a regex and paste it inside the string quotes, intellij automatically escapes it

obsidian osprey
#

but it wouldnt have helped here with the flags

#

since the flag syntax in java is different