cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 9

Problem with regex matching a text block

Jump to solution

Hello all,

I'm trying to match the following in my configs, but it is not matching in NCM.  Through other regex tests, it does match.

tcp-mss {

            ipsec-vpn {

                mss 1360;

            }

        }

Using this regex: ^tcp-mss.*\n.*ipsec-vpn.*\n.*mss 1360;\n.*\n.*}

Any thoughts?

Labels (1)
0 Kudos
1 Solution

When it comes to multi-line matches, another issue to look out for would be the line break styles. Mostly we try to match with \n but there are config files which uses UNIX EOL character "\r\n".

So as a rule of thumb one should use (\r)?\n when trying to match newline characters. If you are not sure, open the config file in Notepad++, go to View -> Show Symbol -> Show End Of Line

View solution in original post

6 Replies
Level 11

Hello,

Depends what you are looking for.

JUN.PNG

I suppose it is Junos OS. The char "^" for beginning of line.

Regards,

Mateusz

0 Kudos

When it comes to multi-line matches, another issue to look out for would be the line break styles. Mostly we try to match with \n but there are config files which uses UNIX EOL character "\r\n".

So as a rule of thumb one should use (\r)?\n when trying to match newline characters. If you are not sure, open the config file in Notepad++, go to View -> Show Symbol -> Show End Of Line

View solution in original post

Thanks for posting this - it solved the problem I was having.

0 Kudos

chrismepa, make sure you mark his answer as correct.

0 Kudos

I wasn't the original poster of the question in this thread - just came across it while searching the forum.  I can't see where I can mark the answer as correct - - I clicked on like if that helps.

0 Kudos

Oh, indeed. Liking it helps as well, so that if other users experience the same issues, the know they can trust the solution. Thank you!

0 Kudos