ArtoAllan Posted June 4, 2021 Share Posted June 4, 2021 Hey guys. I am building a manual scraper for some e-commerce numbers -> google sheet. however since, I am a "noob" and just like to work with things, I am building this the most simple way I possible can. So everything is taken by heading to the website where it should grab the numbers, and copy it in to clipboard and then set variables according so. Later, it will be opening google sheets and entering the data in the correct spots. However, I am trying to replace . in to , with StringRegExpReplace, and it just doesnt do the trick. I am missing something. I can easily have it exchange anything else, but as soon as I want it to exchange only the . it replaces all the numbers. $Test = StringRegExpReplace("715.99", '.', ',') As for example I want this to replace the text to 715,99 (seems stupid, but yea.. google sheets doesnt work with .) But the value I am getting is just alot of commas. What am I doing wrong? I tried putting the . in a variable to see if that helped, but it didnt change a thing. I need help here! Link to comment Share on other sites More sharing options...
Solution FrancescoDiMuro Posted June 4, 2021 Solution Share Posted June 4, 2021 (edited) 2 hours ago, ArtoAllan said: What am I doing wrong? The period in Regular Expressions is the meta character for "every character", so, unless you escape it with \, the function is doing its work You don't really need StringRegExpReplace() to do such a simple task; just use StringReplace(), or, if you want to use SRER because you are a cat (you'll probably know in a few posts), then you should do something like this: #include <StringConstants.au3> Test() Func Test() Local $strTest = "715.99" ConsoleWrite(StringRegExpReplace($strTest, '\.', ',') & @CRLF) ConsoleWrite(StringReplace($strTest, '.', ',') & @CRLF) EndFunc Edited June 4, 2021 by FrancescoDiMuro StringReplace($strPostContent, "comma", "period") JockoDundee and TheXman 2 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
ArtoAllan Posted June 4, 2021 Author Share Posted June 4, 2021 2 minutes ago, FrancescoDiMuro said: The comma in Regular Expressions is the meta character for "every character", so, unless you escape it with \, the function is doing its work You don't really need StringRegExpReplace() to do such a simple task; just use StringReplace(), or, if you want to use SRER because you are a cat (you'll probably know in a few posts), then you should do something like this: #include <StringConstants.au3> Test() Func Test() Local $strTest = "715.99" ConsoleWrite(StringRegExpReplace($strTest, '\.', ',') & @CRLF) ConsoleWrite(StringReplace($strTest, '.', ',') & @CRLF) EndFunc My man! Exactly what I was looking for! $Test = StringRegExpReplace("715.99", '\.', ',') ; <--- simplified That does the trick, thank you soo much for a fast answer buddy! Appreciate it FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 4, 2021 Share Posted June 4, 2021 @ArtoAllan Happy to have helped bud, always a pleasure Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
TheXman Posted June 4, 2021 Share Posted June 4, 2021 1 hour ago, FrancescoDiMuro said: The comma in Regular Expressions is the meta character for "every character" Tiny correction: I think you meant the period (.) in Regular Expressions is the meta character for "any character". FrancescoDiMuro 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 4, 2021 Share Posted June 4, 2021 @TheXman Thanks for the correction! What can I say... You have an eagle eye! TheXman 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
JockoDundee Posted June 4, 2021 Share Posted June 4, 2021 2 hours ago, FrancescoDiMuro said: because you are a cat (you'll probably know in a few posts)... Actually, I think your non-SRE solution is cat proof. Well done! FrancescoDiMuro 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
mikell Posted June 5, 2021 Share Posted June 5, 2021 17 hours ago, JockoDundee said: Actually, I think your non-SRE solution is cat proof. Well done! I agree FrancescoDiMuro 1 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