ASut 0 Posted June 26, 2011 Hi, How can I modify the pattern to make it the output as below 1 ABC 123ABCinstead of 1 12<test>ABC 123ABCWhich means ignore the broken tag. Thanks in advance. $array = StringRegExp('<test>1</test> <test>12<test>ABC</test> <test>123ABC</Test>', '<(?i)test>(.*?)</(?i)test>',3) for $i = 0 to UBound($array) - 1 msgbox(0, "Test - " & $i, $array[$i]) Next Share this post Link to post Share on other sites
Jos 2,217 Posted June 26, 2011 (edited) You are sure that this bit is really the input: "<test>12<test>ABC" and is not "<test>12</test>ABC"? if so try: '<(?i)test>(.*?)<[/](?i)test>' Jos Edited June 26, 2011 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
ASut 0 Posted June 26, 2011 You are sure that this bit is really the input: "<test>12<test>ABC" and is not "<test>12</test>ABC"? if so try: '<(?i)test>(.*?)<[/](?i)test>' Jos I'm very sure it is "<test>12<test>ABC</test>". But the pattern is not work for me. Btw, thanks for the help. Share this post Link to post Share on other sites
SmOke_N 211 Posted June 26, 2011 (edited) "(?i)<test>(.+?)(?=<)" Edited June 26, 2011 by SmOke_N Needed a "Look Ahead" pattern Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
Malkey 231 Posted June 26, 2011 Hi, How can I modify the pattern to make it the output as below 1 ABC 123ABC ... Try this. #Include <Array.au3> ; Positive assertions of both look behind and look ahead. ;$array = StringRegExp('<test>1</test> <test>12<test>ABC</test> <test>123ABC</Test>', "(?i)(?<=<test>)([^<]+)(?=</test>)" ,3) ;or ;$array = StringRegExp('<test>1</test> <test>12<test>ABC</test> <test>123ABC</Test>', "(?i)(?:<test>)([^<]+)(?:</test>)" ,3) ;or $array = StringRegExp('<test>1</test> <test>12<test>ABC</test> <test>123ABC</Test>', "(?i)(?:>)([^<]+)(?:</)" ,3) _ArrayDisplay($array) #cs All patterns return an array of:- 1 ABC 123ABC #ce Share this post Link to post Share on other sites
ASut 0 Posted June 27, 2011 Thanks, them work fine for me. RegExp is very difficult to learn. Share this post Link to post Share on other sites