$userAgent = $ _SERVER // change this to the useragent you want to parse $dd = new DeviceDetector( $userAgent) X.Y) // for other options see VERSION_TRUNCATION_* constants in DeviceParserAbstract class AbstractDeviceParser:: setVersionTruncation( AbstractDeviceParser:: VERSION_TRUNCATION_NONE)
OPTIONAL: Set version truncation to none, so full versions will be returned // By default only minor versions will be returned (e.g.
So in my C# code I build dynamically a regex corresponding to the whole method signature with its parameters, and each parameter can have a default value (which is the regex I ask in this forum thread).Īs you can see, my final regex is bigger than this little part and I cannot see how to divide it in 3 parts.Use DeviceDetector\ Parser\ Device\ AbstractDeviceParser Public string Method1(bool bParam1, string sParam2, int iParam3 = "DefaultValue") The regex I asked you in this forum thread is a little part of my final search and corresponds to the default value of a parameter in a C# method signature :Īnd my final search is the whole method signature and can be : In fact my final aim is to check a method signature in a C# code file : Once again I was not complete in the description of my problem so you could not know. I don't think that your solution with 3 regex can answer my needs. If (match.Success || match1.Success|| match2.Success) Match match2 = regexObj2.Match(sFileContent)
Match match1 = regexObj1.Match(sFileContent) Regex regexObj2 = new Regex(sPatternDataTable3, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline) Regex regexObj1 = new Regex(sPatternDataTable2, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline) string sFileContent = "SomeText = aaabbbccc" //SUCCESS string sFileContent = "SomeText = aaa(bbb)ccc" //SUCCESS string sFileContent = "SomeText = aaa(bbbb.ff" //fail String sFileContent = "SomeText=\"ggghhh\"jjjkkk\"" //fail string sFileContent = "SomeText = " // success The solution you propose almost suits my goal but not exactly, because I was not clear in my explanations.Īccording to your description, I suggest you could try to use three regex to check the string. Match match = regexObj.Match(sFileContent) RegexObj = new Regex(sPatternDataTable, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline)
string sFileContent = "SomeText = aaa bbb)ccc" //fail string sFileContent = "SomeText = aaa bbb,ccc" //fail string sFileContent = "SomeText=\"ggghhh\"jjjkkk\"" //fail string sFileContent = "SomeText=\"dddee efff\"\"gg" //fail string sFileContent = "SomeText = " //success String sFileContent = "SomeText = " // success More details, you could refer to follow codes: Regex regexObj Regex : how to match double characters and exclude single characterĪccording to your description, I suggest you could refer to follow codes: string sPatternDataTable = "^SomeText[