regex - Java Pattern.compile expression - "/login?(\\?.+)?" -


i trying understand regular expression given below:

"/login?(\\?.+)?" 

i have gone through java docs, not able understand purpose of expression.

i understand looks string starts /login, after characters ?(\\?.+)? represent? please me in understanding this.

  • /login matches literal characters /login
  • the ? makes n optional
  • the (parentheses) capture match inside group 1
  • /login
  • \\? matches literal ?. in normal regex \?, in java string backslash has escaped backslash
  • the .+ matches 1 or more characters, can include spaces , dog!

sample matches

/logi /login /login?a /logi?an /logi?and dog 

general answers "what regex mean?

  1. you can use tool such see regex101 play regex. right pane explains token token.
  2. there several explaining tools based on same original perl library, such this one, on 1 of answers based.
  3. the ultimate answer can found in mastering regular expressions, 3rd ed. , several excellent online tutorials, including regex faq on site.

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -