1

I would like to know the meaning of the regular expression used in mule expression language

I have a choice component that uses the following expression

regex('^[\\w\\s]+=.*',payload['Created_Package']) != null

Could some one please explain the meaning of the above expression?

Robin
  • 9,415
  • 3
  • 34
  • 45
madhu
  • 87
  • 2
  • 12
  • 1
    Have you tried yet any of the online tools ([regex101](http://regex101.com/r/zT8yN3), [regex explainer](http://rick.measham.id.au/paste/explain.pl?regex=%5E%5B%5Cw%5Cs%5D%2B%3D.*)...) that offer to do that ? – Robin Jun 12 '14 at 12:39

1 Answers1

1

The regular expression first starts at the beginning of the string, hence the ^ anchor, then matches any character that is considered a word character (a-z, A-Z, 0-9, _) or whitespace (1 or more times) followed by matching an equal = sign. Finally matching any character except newline (0 or more times)

Some valid matches would be:

foo=bar
123=456
   =foo
foo=&^&#$$#[]&^#

Some invalid matches would be:

*#*=dfds
[foo]=bar
1.2.3=456

A good tool that offers explanation of a regular expression, Explain Regular Expression

hwnd
  • 69,796
  • 4
  • 95
  • 132