The expression of Java Pattern.compile is "/login?(\\?.+)?"

I am trying to understand the regex below:

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

I looked through Java documents , but I cannot clearly understand the purpose of this expression.

I understand that he is looking for a line starting with /login, and then what do the characters mean ?(\\?.+)?? Please help me in understanding this.

+4
source share
4 answers
  • /login matches literal characters /login
  • ?makes noptional
  • (parentheses) record match within group 1
  • /login
  • \\? ?. \?, Java
  • .+ , spaces and my dog!

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

" ?

  • , See regex101, . .
  • , Perl, , .
  • " ", 3- . -, .
+3

?some-text-here /login. , /login? n :

:

/logi
/login
/logi?something
/login?something

- Regex

+9

/logi, n (?= ), (() limit a group), ? (- \, ?), (.+, .= , += ).

+1

logi - .

  • n? , n
  • ()? , ()
  • \\? , \
  • .+ , ( )
-1

Source: https://habr.com/ru/post/1546093/


All Articles