Reputation: 49
I have the following regular expression which I am analyzing from last few days.
/8c/4!n1!x4!n
Can anyone tell what does the forward slash mean in this regex.
Upvotes: 1
Views: 17869
Reputation: 21
That's not a regex, although it is similar; it is a SWIFT financial message field format definition.
See for example page 8 of https://www2.swift.com/uhbonline/books/public/en_uk/stdsdkug_20090925/stds_dev_kit_user_guide.pdf
A rough translation might be literal character "/", followed by up to 8 alphabetic chars, followed by a "/", then exactly 4 numeric, exactly 1 alphanumeric, and exactly 4 numeric chars. The "!" denotes "Exactly".
Upvotes: 2
Reputation: 189926
Without any context such as a particular programming language's conventions, a forward slash in a regex has no special meaning; it simply matches a literal forward slash.
In some languages, such as sed
, Awk, Perl, and PHP, slashes are used around regular expressions in some contexts.
/foo/n
This sed
script, for example, selects the n
(next line) action if the current pattern space contains text which matches the regular expression foo
. As you can see, the slashes are used to bracket the regular expression.
As an aside, in sed
and Perl (and PHP?) the slash character is simply the default, and you can switch to a different nonalphabetic delimiter if you like.
Upvotes: 7