Knowledge Search


×
 

[Junos Content Encore (Formerly MFC)] how to verify if the regex statement is correct

  [KB23319] Show Article Properties


Summary:
This article provides information on how to verify if the regex statement is correct.
Symptoms:
  • When configuring the namespace, you may create a regex statement as the value for a particular domain.
  • How to verify if it is going to correctly match?
Cause:

Solution:
From the JCEell, in the /opt/nkn/bin directory, the nknregex tool is present; it is a regex checker. This tool allows you to verify if the regex statement is behaving as expected. You need a licensed JCEicense is required to access the shell).


Logon to the shell with _shell:
1 (config) # _shell
[admin@1 bin]#


[admin@1 bin]# cd /opt/nkn/bin


[admin@1 bin]# ./nknregex
[./nknregex]:
Evaluate regex against data.

Options:
-d --data
-e --expression
-f --file
-h --help
-m --matcher
-v --verbose

Examples:

[admin@1 bin]# ./nknregex -v -e "^.*juniper\.net" -d www.juniper.net
Match


[admin@1 bin]# ./nknregex -v -e "^.*juniper\.net" -d www.jnpr.net
No Match, nkn_regexec(), rv=1, errbuf=[No match]


[admin@1 bin]# ./nknregex -v -e '^[a-f,0-9] \.(origin\.|cdn\.)?cms\.xxx\.com:80$' -d 'abcdef01.origin.cms.xxx.com:80'
Match


[admin@1 bin]# ./nknregex -v -e '^(cms[0-9] ).*(qcg[0-9]+|dc2|af1)\.yyy\.com:80$' -d 'cms123.x.y.qcg0.yyy.com:80'
Match



[admin@1 bin]# ./nknregex -m -e 'http://113\.21\.241\.[1-9]{1,2}/videoplayback\?.*\&id=([^\&]+).*' -d 'http://113.21.241.12/videoplayback?xxx&id=1xxuuu'
match[0]: http://113.21.241.12/videoplayback?xxx&id=1xxuuu
match[1]: 1xxuuu
Related Links: