toto Posted March 9, 2005 Posted March 9, 2005 $phrase = "BONJOUR, MONSIEUR"Is someone can indicate me how can i do with regular expression to transform "BONJOUR, MONSIEUR" in "BONJOUR CHER MONSIEUR" replacing "," with "CHER"Thanks in advance
steveR Posted March 9, 2005 Posted March 9, 2005 (edited) $phrase = "BONJOUR, MONSIEUR" $r = StringRegExpReplace( $phrase, "," , " CHER" ) MsgBox(0, "", $r) EDIT: the solution above is using the beta Edited March 9, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
toto Posted March 9, 2005 Author Posted March 9, 2005 $phrase = "BONJOUR, MONSIEUR"$r = StringRegExpReplace( $phrase, "," , " CHER" )MsgBox(0, "", $r)EDIT: the solution above is using the beta<{POST_SNAPBACK}>Sorry i don't formulate correctly my demand$phrase= "Bonjour, 01000, LYON"I want to eliminate the comma after 01000 searching in the phrase 01000, replacing with 01000. may be the second var will be 'Bonjour, 02000, AISNE" and with this sentence it's 02000, which need to be remplaced by 02000In fact i load a file composed of 1000 adress in which the zip code and the town are separated by a comma and i want to eliminate the comma betwween zip code and town.Particularity : The position of the zip code isn't a fix position.Hope to find a solution.Thanks
Nutster Posted March 9, 2005 Posted March 9, 2005 Sorry i don't formulate correctly my demand$phrase= "Bonjour, 01000, LYON"I want to eliminate the comma after 01000 searching in the phrase 01000, replacing with 01000. may be the second var will be 'Bonjour, 02000, AISNE" and with this sentence it's 02000, which need to be remplaced by 02000In fact i load a file composed of 1000 adress in which the zip code and the town are separated by a comma and i want to eliminate the comma betwween zip code and town.Particularity : The position of the zip code isn't a fix position.Hope to find a solution.Thanks<{POST_SNAPBACK}>if I understand what you want, try$phrase = "Bonjour, 02000, AISNE" $r = StringRegExpReplace( $phrase, "," , " ", 0) MsgBox(0, "", $r)This code replaces each comma with a space. How's that? David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
steveR Posted March 10, 2005 Posted March 10, 2005 (edited) I think he just wants the comma after the numbers deleted. If so, try this:$sPattern = "(\d+)," $sTest = "BONJOUR, 12345, MONSIEUR" $sRes = StringRegExpReplace($sTest, $sPattern, "\1") MsgBox(0,"Result",$sRes)That will delete a comma that immediately follows a group of numbers.EDIT:This will delete the comma if there happens to be any spaces (or not) between the numbers and the comma.$sPattern = "(\d+) *," $sTest = "BONJOUR, 12345 , MONSIEUR" $sReplace = "\1" $sResult = StringRegExpReplace($sTest, $sPattern, $sReplace ) MsgBox(0,"Result",$sResult) Edited March 10, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
toto Posted March 10, 2005 Author Posted March 10, 2005 I think he just wants the comma after the numbers deleted. If so, try this:$sPattern = "(\d+)," $sTest = "BONJOUR, 12345, MONSIEUR" $sRes = StringRegExpReplace($sTest, $sPattern, "\1") MsgBox(0,"Result",$sRes)That will delete a comma that immediately follows a group of numbers.EDIT:This will delete the comma if there happens to be any spaces (or not) between the numbers and the comma.$sPattern = "(\d+) *," $sTest = "BONJOUR, 12345 , MONSIEUR" $sReplace = "\1" $sResult = StringRegExpReplace($sTest, $sPattern, $sReplace ) MsgBox(0,"Result",$sResult)<{POST_SNAPBACK}>Thanks stever that's all i want
supergg02 Posted March 12, 2005 Posted March 12, 2005 $phrase = "BONJOUR, MONSIEUR"$r = StringRegExpReplace( $phrase, "," , " CHER" )MsgBox(0, "", $r)EDIT: the solution above is using the beta<{POST_SNAPBACK}>Please, in what beta version this function (StringRegExpReplace) is used ?I tryed with autoit v3.1.1 (beta) but there is no StringRegExpReplace function in help File.
steveR Posted March 12, 2005 Posted March 12, 2005 Here:http://www.hiddensoft.com/fileman/users/jpm/AutoIt3-gui/ AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
supergg02 Posted March 12, 2005 Posted March 12, 2005 Here:http://www.hiddensoft.com/fileman/users/jpm/AutoIt3-gui/<{POST_SNAPBACK}>Thinks a lot steve for this rapid Replay !just one question about installing it:should i juste replace autoit.exe or past all dir and file in the last autoit3 directory ?
steveR Posted March 12, 2005 Posted March 12, 2005 Paste it all in the main AutoIt directory except AutoItSC.bin which you put in AutoIt3\Aut2Exe\ folder AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
supergg02 Posted March 13, 2005 Posted March 13, 2005 Paste it all in the main AutoIt directory except AutoItSC.bin which you put in AutoIt3\Aut2Exe\ folder<{POST_SNAPBACK}>Thinks again!I'm sure that RegExp techinique is very usefull but it is more difficult to understand...I juste tryed to use it to detag html text (just one ligne) with no succeed!Please, what $pattern we should use to find all think between 2 given substrings ?exemple:my html text is: 1",'','102,00 <font size="-1" color="#666666">EUR</font>','','',0,my goal is to eliminate/replace all thing between < and > (detag all tags and leave only txt). so the result should be 1",'','102,00 EUR ','','',0,This exemple is very useful for all html conversion question (html2txt,html2csv,...etc)Thinks for any help!
steveR Posted March 13, 2005 Posted March 13, 2005 I just found out about reg exp last year and now I cant live without them. Do a google search for 'regular expressions'. You will find tons of sites devoted to them.They can be confusing at first, but keep at it. I guarentee you will find uses for them all the time.Im trying to figure you're problem out now, but here's a good link to find pre-made reg exp :http://www.regexlib.com/DisplayPatterns.aspx AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
supergg02 Posted March 13, 2005 Posted March 13, 2005 I just found out about reg exp last year and now I cant live without them. Im trying to figure you're problem out now, but here's a good link to find pre-made reg exp :http://www.regexlib.com/DisplayPatterns.aspx<{POST_SNAPBACK}>good link ! I tested this pattern:</?(\w+)(\s*\w*\s*=\s*("[^"]*"|'[^']'|[^>]*))*|/?>and it work as a charme in this site web (Online test Form here: http://www.regexlib.com/REDetails.aspx?regexp_id=236)but when i test the same think with autoit, it crach !! maybe it is a bug??
steveR Posted March 13, 2005 Posted March 13, 2005 (edited) Their reg exp operators might be different from AutoIt's. There are different standards floating around, e.g. Linux, .NET, Perl. All are similar but have a few different operators.You have to try to translate their reg exp to AutoIt's form.EDIT: Try This:$test = '<html>abc123<font size="-1" color="#666666">EUR</font>123abc</html>' $pattern = "(<.+?>)" $test = StringRegExpReplace($test, $pattern, " ", 0) MsgBox(8192,"err:"&@error&"Ext:"&@extended, $test) Edited March 13, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
supergg02 Posted March 13, 2005 Posted March 13, 2005 Their reg exp operators might be different from AutoIt's. There are different standards floating around, e.g. Linux, .NET, Perl. All are similar but have a few different operators.You have to try to translate their reg exp to AutoIt's form.<{POST_SNAPBACK}>ahhhh, ok Steve ! I will try again (but i need to learn...) It take a lot of time but with some useful tools like Regulator http://regex.osherove.com/ and other tutorials like here http://www.codeproject.com/dotnet/RegexTutorial.asp i hope practice quickly ! Regulator is able to import regexp for a RegexpLib.com database, test your own regexp, debug,...AND opensource !!!
steveR Posted March 13, 2005 Posted March 13, 2005 Yes, I have that too. Very useful tool! Also, I don't know what text editor you use, but most support reg exp nowadays. It's great if you learn their syntax too. (UltraEdit, TextPad, EditPlus, NotePad2, MS Word). A lot of apps in general now support reg exp. AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
supergg02 Posted March 13, 2005 Posted March 13, 2005 (edited) ok now i found the solution: the pattern is:<.[^>]*> it catch all tags and leave only text.... <tag property1=value property2=value....> and my texte </tag>.....Func html2txt($html)$pattern="<.[^>]*>"$Html2TxT=StringRegExpReplace($html,$pattern,"")Return $Html2TxTEndFuncThinks a lot to steve for his precious help and idea ! Edited March 13, 2005 by supergg02
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