tags:

views:

84

answers:

5

^.+\\(.*\\)

I am struggling to work this one out, any help would be greatly appreciated...

also is there a site that lets youu paste in a regular expression then spits out in plain text what it means?

+1  A: 
  • ^ is the start of line
  • . is any (non-newline) character
  • .+ is one or more of any (non-newline) character
  • .* is zero or more of any (non-newline) character

Then, there are two possibilities for \\( and \\):

  • \\ is a backslash, and ( opens a group.
  • \\( is a literal opening parenthesis.
Sjoerd
\( is literal opening parenthesis. \\( is \ followed by a group start
simendsjo
+1  A: 
^ text starts with
. any character
+ 1 or more instances
\\ \ character
( group start
* 0 or more characters
) group end

So.. The string starts with several any characters followed by \ followed by optinally several any characters followed by \

simendsjo
+1  A: 

^ Start at the beginning of the string
.+ Match one or more of any kind of character (except newline)
\\ Literal backslash
( Start group
.* Zero or more of any kind of character (except newline)
\\ Literal backslash
) End group

After matching, the captured group will have a backslash and any number of characters after it.

Javier Badia
+4  A: 

also is there a site that lets youu paste in a regular expression then spits out in plain text what it means?

For instance the Regular Expression Analyzer gives this result for your regex ^.+\\(.*\\):

Sequence: match all of the followings in order
    BeginOfLine
    Repeat
        AnyCharacterExcept\n
        one or more times
    (
    Repeat
        AnyCharacterExcept\n
        zero or more times
    )
tanascius
Damn nice tool. Didn't know that one
simendsjo
+2  A: 

Others have already described it's components, so I'll give you some examples - allthough I'm not sure what \\( and \\) stands for. It depends on your regexp-engine. If they match literal parenthesis, this regexp will match the following strings:

abc(def)
abcdef()

but won't match these:

abc
(abc)
abc(def)ghi
(abc)def

In case they match literal slashes and open/close a group, your regexp will match:

abc\def\
craesh
Thanks that is a really good explanation... I will expect your answer
Lizard