SBM ModScript Reference → Programming SBM ModScript → Constants → RegexOptionBitsConstants
Constant object that contains bits for Regex.Compile() options. Values can be combined using bit or operator "|".
SBM ModScript version: 11.3.
var regex = Regex(); //To test for a valid phone number var subCheck = "(\\+\\d{1,2}\\s*)?\\(?\\d{3}\\)?\\s*[\\.-]?\\s*\\d{3}\\s*[\\.-]?\\s*\\d{4}"; var testNumbers = "123-456-7890 | (123)456-7890 | 123 456 7890 | 123,456,7890 | +91 (123) 456-7890"; regex.Compile(subCheck, RegexOptionBitsConstants.IGNORECASE | RegexOptionBitsConstants.MULTILINE); if ( regex.Matches(testNumbers) ) { Ext.WriteStream("Matches:<br />${regex.GroupVal(0)}"); while( regex.MatchesAgain() ) { Ext.WriteStream("<br />${regex.GroupVal(0)}"); } }
Result:
Matches: 123-456-7890 (123)456-7890 123 456 7890 +91 (123) 456-7890
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.