pintas 0 Posted June 2, 2011 I don't know that because i'm not perfectly fluent in English or not, but StringRegExp still seems very complicated to me. I have a PHP file with this type of content: $PUBLISHED_FOLDERS = array( "1" => array("name" => "Client1", "path" => "/BEA/clientlogin1"), "2" => array("name" => "Client2", "path" => "/CENTROOESTE/clientlogin2"), "3" => array("name" => "Client3", "path" => "/COMEC"), ); So, i do a FileRead and a StringRegExp to extract the contents BEA, CENTROOESTE and COMEC like this: $sFile = FileRead("configuration.php") $aFilter = StringRegExp($sFile, '(?U)"path" => "/(.*)\W', 3) And it works like a charm, but today i needed to add a value with a symbol (no '/' ofcourse) or a space and in the results nor the symbols nor the spaces appear. For example, if i have a value 'CENTRO OESTE' instead of 'CENTROOESTE', only the first word appears. And if i have a value 'B&A' instead of 'BEA', only 'B' appears in the result. Can i add the ability to not ignore symbols or spaces in the StringRegExp above? Ofcourse the '/' couldn't be ignored, as i only need the first value after the first '/'. I hope you guys can help me with this, and i hope i'm not being to complicated in the explanation. Share this post Link to post Share on other sites
iamtheky 927 Posted June 2, 2011 Im sure a cool kid will do it one regular expression, i need one and a replace #include <array.au3> $sFile = FileRead("configuration.php") $aFilter = StringRegExp($sFile, '(?U)"path" => "/(.*?)"', 3) for $i = 0 to ubound($aFilter) - 1 $aFilter[$i] = stringregexpreplace ($aFilter[$i] , "/(.*)" , "") Next _ArrayDisplay($aFilter) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Share this post Link to post Share on other sites
sahsanu 28 Posted June 2, 2011 And it works like a charm, but today i needed to add a value with a symbol (no '/' ofcourse) or a space and in the results nor the symbols nor the spaces appear. For example, if i have a value 'CENTRO OESTE' instead of 'CENTROOESTE', only the first word appears. And if i have a value 'B&A' instead of 'BEA', only 'B' appears in the result. Can i add the ability to not ignore symbols or spaces in the StringRegExp above? Ofcourse the '/' couldn't be ignored, as i only need the first value after the first '/'. Till something better.. try this: $aFilter = StringRegExp($sFile, '"path" => "/(.+?)["|/]', 3) Share this post Link to post Share on other sites
pintas 0 Posted June 2, 2011 And it works too! I really need to fully understand that StringRegExp... Thanks guys! You saved my day! Share this post Link to post Share on other sites