Regular Expression Time Delay

I'm trying to match something like

foo: anything after the colon can be matched with (.*)+
foo.bar1.BAZ: balh5317{}({}(

This is the regex that I use:

/^((?:(?:(?:[A-Za-z_]+)(?:[0-9]+)?)+[\.]?)+)(?:\s)?(?:\:)(?:\s)?((?:.*)+)$/

Sorry inconsistent groups and extra parsers, this compiles from the builder class

This works on examples. The problem occurs when I try to insert a line like this:

foo.bar.baz.beef.stew.ect.and.forward

I need to be able to check strings like this, but the regex engine expires or works endlessly (as far as I can tell) after a certain amount foo.each time.

I am sure that this is a logical problem that I could figure out, but unfortunately I did not master the regular expression, and I was hoping that a more experienced user could shed some light on how I can make this more efficient.

, , :

Property Name: can contain A-z, numbers, and underscores but can't start with a number

<Property Name>.<Property Name>.<Prop...:<Anything after the colon>

!

+4
1

:

^((?:(?:(?:[A-Za-z_]+)(?:[0-9]+)?)+[\.]?)+)(?:\s)?(?:\:)(?:\s)?((?:.*)+)$


 ^                                  # Anchors to the beginning to the string.
 (                                  # Opens CG1
     (?:                            # Opens NCG
         (?:                        # Opens NCG
             (?:                    # Opens NCG
                 [A-Za-z_]+         # Character class (any of the characters within)
             )                      # Closes NCG
             (?:                    # Opens NCG
                 [0-9]+             # Character class (any of the characters within)
             )?                     # Closes NCG
         )+                         # Closes NCG
         [\.]?                      # Character class (any of the characters within)
     )+                             # Closes NCG
 )                                  # Closes CG1
 (?:                                # Opens NCG
     \s                             # Token: \s (white space)
 )?                                 # Closes NCG
 (?:                                # Opens NCG
     \:                             # Literal :
 )                                  # Closes NCG
 (?:                                # Opens NCG
     \s                             # Token: \s (white space)
 )?                                 # Closes NCG
 (                                  # Opens CG2
     (?:                            # Opens NCG
         .*                         # . denotes any single character, except for newline
     )+                             # Closes NCG
 )                                  # Closes CG2
 $                                  # Anchors to the end to the string.

[0-9] \d, ( ). , .

^((?:(?:[A-Za-z_]+\d*)+\.?)+)\s?\:\s?((?:.*)+)$

\s . * [\s\S]*, , , +, [\s\S].

^((?:(?:[A-Za-z_]+\d*)+\.?)+)\s?\:([\s\S]+)$
                      ^

, + . , , , , .

^((?:[A-Za-z_]+\d*\.?)+)\s?\:([\s\S]+)$

:

 ^                          # Anchors to the beginning to the string.
 (                          # Opens CG1
     (?:                    # Opens NCG
         [A-Za-z_]+         # Character class (any of the characters within)
         \d*                # Token: \d (digit)
         \.?                # Literal .
     )+                     # Closes NCG
 )                          # Closes CG1
 \s?                        # Token: \s (white space)
 \:                         # Literal :
 (                          # Opens CG2
     [\s\S]+                # Character class (any of the characters within)
 )                          # Closes CG2
 $                          # Anchors to the end to the string.

[\s\S]+ .*, . , , .

, , (?:.*)+. match 0 or more characters 1 or more times ( xufox ).

, .. , .

, foo.ba5r, , .

^([A-Za-z_]\w*(?:\.[A-Za-z_]+\w*)*)\s?\:([\s\S]+)$

:

 ^                          # Anchors to the beginning to the string.
 (                          # Opens CG1
     [A-Za-z_]              # Character class (any of the characters within)
     \w*                    # Token: \w (a-z, A-Z, 0-9, _)
     (?:                    # Opens NCG
         \.                 # Literal .
         [A-Za-z_]          # Character class (any of the characters within)
         \w*                # Token: \w (a-z, A-Z, 0-9, _)
     )*                     # Closes NCG
 )                          # Closes CG1
 \s?                        # Token: \s (white space)
 \:                         # Literal :
 (                          # Opens CG2
     [\s\S]+                # Character class (any of the characters within)
 )                          # Closes CG2
 $                          # Anchors to the end to the string.
+2

All Articles