ATR Posted April 9, 2014 Share Posted April 9, 2014 (edited) Hi all, I have a problem with a regex expression. I have a string with many numbers and i want remove all between them. My string <tr> <td>30/09/2013</td> <td> 69 290 € </td> <td> 9 980 </td> <td></td> </tr> And I want the result is ;~ <tr> <td>30/09/2013</td> <td> 69290 </td> <td> 9980 </td> <td></td> </tr> Stringstripws don't work because it's not spaces between numbers. I thing we want use [^d] but I have not find solution. Thanks in advance The string is in the file Code_source_html.html Edited April 9, 2014 by ATR Link to comment Share on other sites More sharing options...
mikell Posted April 9, 2014 Share Posted April 9, 2014 (edited) $str = "<tr> <td>30/09/2013</td> <td> 69Â 290 </td> <td> 9Â 980 </td> <td></td> </tr> <tr> <td>30/09/2012</td> <td> 46Â 350 € </td> <td> 1Â 280 </td> <td></td> </tr> <tr> <td>30/09/2011</td> <td> 12Â 030 </td> <td> 20Â 260 </td> <td></td> </tr> </tbody> </table>" $res = StringRegExpReplace($str, '\h*(\d+)[^\d/]+(\d+)[^<]*', '$1$2') msgbox(0,"", $res) ? Edited April 9, 2014 by mikell ATR 1 Link to comment Share on other sites More sharing options...
ATR Posted April 10, 2014 Author Share Posted April 10, 2014 It doesnt work properly Link to comment Share on other sites More sharing options...
sahsanu Posted April 10, 2014 Share Posted April 10, 2014 Hello, I think you should provide a little more info regarding the issue instead of "it doesnt work properly" ;-) Cheers, sahsanu Link to comment Share on other sites More sharing options...
Solution iamtheky Posted April 10, 2014 Solution Share Posted April 10, 2014 (edited) $str = fileread("Code_source_html.html") msgbox(0, '' , stringreplace($str , " " , "")) in the string replace instead of space, i typed alt+0160 and with all spaces including those removed: $str = fileread("Code_source_html.html") msgbox(0, '' , stringstripws(stringreplace($str , " " , ""),8)) Edited April 10, 2014 by boththose ATR 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
jdelaney Posted April 10, 2014 Share Posted April 10, 2014 _IETableWriteToArray IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
mikell Posted April 10, 2014 Share Posted April 10, 2014 Please explain, I tried this and it works $str = fileread("Code_source_html.html") $res = StringRegExpReplace($str, '\h*(\d+)[^\d/]+(\d+)[^<]*', '$1$2') msgbox(0,"", $res) Link to comment Share on other sites More sharing options...
ATR Posted April 10, 2014 Author Share Posted April 10, 2014 Please explain, I tried this and it works $str = fileread("Code_source_html.html") $res = StringRegExpReplace($str, '\h*(\d+)[^\d/]+(\d+)[^<]*', '$1$2') msgbox(0,"", $res) In fact your code replace all between numbers : 123 text with text 456 the result is 123456, but I don't want this result. I want only caracters not in a-zA-Z and 0-9 I don't say if you have seen in the file, but characters between numbes it's not space... Link to comment Share on other sites More sharing options...
iamtheky Posted April 10, 2014 Share Posted April 10, 2014 (edited) it is a space, just a "No-Break Space" also known as U+00A0 or the alt code 0160. Any reason my solution in post #5 is failing your criteria? Edited April 10, 2014 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted April 10, 2014 Share Posted April 10, 2014 I have a string with many numbers and i want remove all between them. My string <tr> <td>30/09/2013</td> <td> 69 290 € </td> <td> 9 980 </td> <td></td> </tr> And I want the result is ;~ <tr> <td>30/09/2013</td> <td> 69290 </td> <td> 9980 </td> <td></td> </tr> It's exactly what the regex does, it removes all (including xA0) But this looks like a wrong way so can you please post a clear sample of expected result ? Link to comment Share on other sites More sharing options...
Wilenty Posted April 10, 2014 Share Posted April 10, 2014 (edited) It's exactly what the regex does, it removes all (including xA0) But this looks like a wrong way so can you please post a clear sample of expected result ? $SomeString="<tr> <td>30/09/2013</td> <td> 69 290 € </td> <td> 9 980 </td> <td></td> </tr>"; set, or get from HTM(L) $timer=TimerInit() $NewString=StringRegExpReplace($SomeString , "&.*;" , ""); replace from: "&", until: ";", to: "" $ReplacedString=StringReplace($NewString , " " , ""); replace: " ", to "" (all spaces) $Super=StringRegExpReplace($NewString , "(\d)\s(\d)" , "$1$2"); replace " " between the digit to: "" msgbox(0, 'Timer: ' & TimerDiff($timer) & " ms" , "Some String :" & $SomeString & @CRLF & _ "NewString (&*;) : " & $NewString & @CRLF & _ "ReplacedString ( ): " & $ReplacedString & @CRLF & _ "WhatYouWant : " & $Super) Greetings (P.S. Give me +1 if it's help You) :-) Edited April 10, 2014 by Wilenty Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now