ForNext
Only Do What Only You Can Do
052. regex match
Hyperpolyglot C++ Style Languages: C++, Objective C, Java, C# より (2012.05.08)
VBScript
JScript
Perl
PHP
Python
Ruby
PowerShell
Scala
F#
C
C++
#include <boost/xpressive/xpressive.hpp> using namespace boost::xpressive; sregex re = sregex::compile(".*ll.*"); smatch matches; string s("hello"); bool is_match = regex_match(s, matches, re);
C++Builder
VC++
C#
using System.Text.RegularExpressions; Regex regex = new Regex("ll"); bool isMatch = regex.IsMatch("hello");
Java
boolean isMatch = "hello".matches(".*ll.*");
Objective-C
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @".*ll.*"]; BOOL is_match = [pred evaluateWithObject:@"hello"];