How to use php pattern Regex in Delphi -


Most of the time, when I look for reggae patterns, I get some php code, and then "traslate" The big problem in Delphi for Delphi is that php migrations do not work in Delphi, but if you ignore them most of the time then everything is fine. But not in the next example, where you extract / x from the pattern, the function preg_match_all does not output to any value.

This is the code in PHP:

  $ pattern = "/ \ n". "\ S (counter \\ ([^)] * \\?)) | \ N". "\ A (counter \\ ([^)] * \\?)) | \ N". "\ S ([\" ']) ((?: [^ \ "'] | \\\\ [\" ']) +) (? & Lt;! \\\\) \\ 3 | \ N "." \ A ([\ "']) ((?: [^ \"'] | \\\\ [\ "']) +) (? & Lt ;! \\\\) \\ 5 | \ n "" \ S ([^ \ s \ "'] +). \ n "." \ A ([^ \ s \ "'] +) \ n". "/ Xi"; Preg_match_all ($ pattern, '"file" counter (file)', $ match, PREG_SET_ORDER);   

This output is:

  array (size = 2) 0 = & gt; Array (size = 7) 0 = & gt; String '' file '' (length = 7) 1 = & gt; String '' (length = 0) 2 = & gt; String '' (length = 0) 3 = & gt; String '' (length = 0) 4 = & gt; String '' (length = 0) 5 = & gt; String '' (length = 1) = 6 = & gt; String 'file' (length = 5) 1 = & gt; Array (size = 2) 0 = & gt; String 'counter (file)' (length = 14)   

I did this in Delphi:

  type TMatches = array of arrays array; Var matches: TMatches; Pattern: = '/ \ n' + '\ S (counter? \\ ([^]] * \\)) | \ N '+' \ A (counter? \\ ([^)] * \\)) | \ N '+' s ([\ "']] ((?: [^ \"' '] | \\\\ [\ "' ']) +) (? & Lt ;! \\\\) \ \ 3 | \ n '+' \ a ([\ "'']) ((?: [^ \" ''] | \\\\ [\ "'']) +) (? & Lt;! \ \\\) \\ 5 | \ n '+' \ s ([^ \ s \ "''] +) | \ n '+' \ A ([^ \ s \" ''] +) \ n ' RegExMatchAll RegExMatchAll (function), RegExMatchAll (Regardless of the page, '' Page '' (pages) 'matches);   

I get the RegExMatchAll function here and in most cases:

  Process RegExMatchAll (Pattern: String; Subject: String; Out Matches: TMTs); Var D, SD: Integer; Reggae: Tragx; Rigguitcup: TGUF Collection; Resol: TMH Start Reggae: Reggae: Reggae: RegColl: RegEx.Matches; SetLength (Match, RegColl.Count); // Invitation to D. narrow [Ar [x]]: = 0 RegCroupColl: RegGroupColl: RegColl.Item [D] group; setline (match [d], reggroup call.); // Numero de grupos [array [de] [sd]] sd: = 0 to RegGroupColl.Count - 1 Make Mail [D] [SD]: = RegGroupColl.Item [sD]. Price; End; End;   

Besides, I change # 13 # 10, and in fact does not talk, my mail is empty. I know that a difficult pattern is regex, but if finally we can solve it issue, it would be great, there are lots of PHP ridge codes and if we can know how to use it in Delphi then it's Delphi Good for developers.

As far as I can see, the Repex support of PPR has been built on PCR. As Delphi is what you see using. Although I'm guessing because you can not say it anywhere, however, I think this is a fairly safe assumption.

In PHP, x modifier PCRE_EXTENDED < / code> Flag is the option of the same setting in Delphi when you call matching then pass that option

on one hand. Please do not post important code using off-site link. We should not leave the question to know what your code is that a reader should be able to get all information directly from the question. Anyway, a reader would wonder how the Delphi Rezox library uses this answer, and that you are calling matching .

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -