gcue Posted September 9, 2020 Posted September 9, 2020 (edited) hello world i am trying to replace the text "(see section B)" with '(<font color="FF8300">see section B2</font>)' - the trick is B might be different combination of letters and numbers $action_item = "(see section B)" $action_item = StringRegExpReplace($action_item, "(see section [\d])", '(<font color="FF8300">see section [\d]</font>') thank you for your help and this working example would be very helpful for future cases Edited September 9, 2020 by gcue
Trong Posted September 9, 2020 Posted September 9, 2020 For fun 🤣 Because I was stupid, so I only knew how to do that #include <String.au3> Global $iString0 = "(see section B)" Global $iString1 = "see section" Global $iString2 = ")" Global $iStringX = '(<font color="FF8300">' Global $iStringY = '</font>)' Global $StringK, $StringOUT Global $aRet = _StringBetween($iString0, "(" & $iString1, $iString2) If IsArray($aRet) Then $StringK = $aRet[0] $StringOUT = $iStringX & $iString1 & $StringK & $iStringY MsgBox(64 + 262144, $StringK, $StringOUT) EndIf Regards,
gcue Posted September 9, 2020 Author Posted September 9, 2020 thanks i tried this - seems to work but not sure if its safe $action_item = StringReplace($action_item, "(see", '(<font color="FF8300">see') $action_item = StringReplace($action_item, ")", '</font>)')
mikell Posted September 9, 2020 Posted September 9, 2020 This might work... $action_item = "abcd (see section A1B2c3) 1234" $action_item = StringRegExpReplace($action_item, "(see section \w+)", '<font color="FF8300">$1</font>') Msgbox(0,"", $action_item) Trong 1
Trong Posted September 9, 2020 Posted September 9, 2020 mikell talented, someone I always admire! 🥰 FrancescoDiMuro 1 Regards,
gcue Posted September 9, 2020 Author Posted September 9, 2020 works like a charm. $1 ! thanks for the help and example Mikell +mikell for president+
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