TheXman Posted July 23, 2023 Share Posted July 23, 2023 (edited) 30 minutes ago, mikell said: May I add, don't double the backslash before Q and E . If you do this, you match the literals "\Q" and "\E" You aren't using the StringFormat() function to build the string, which is why the double backslashes were used. As was mentioned and shown earlier, the StringFormat() could have easily been replaced with regular concatenation, in which case, there isn't a need for the double backslash. Edited July 23, 2023 by TheXman 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...
mikell Posted July 24, 2023 Share Posted July 24, 2023 Sorry. I misread your code and didn't pay attention enough to this StringFormat thing I personally never StringFormat'ed a whole pattern - regex is complicated enough as it is Link to comment Share on other sites More sharing options...
fraizor Posted July 24, 2023 Author Share Posted July 24, 2023 (edited) 20 hours ago, TheXman said: I made it case-sensitive for a reason. If it is not case-sensitive, you may change the case of words you did not mean to change. If it is case-sensitive, then the replacement string can be made to match the case of the search string. In any case, your modification to make it case-insensitive works for me. https://regex101.com/r/AJYOL8/1 Unfortunately the regex has a bug it is trying to replace "float" which is part of a tag https://regex101.com/r/AJYOL8/1 Edited July 24, 2023 by fraizor AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
OJBakker Posted July 24, 2023 Share Posted July 24, 2023 It's not a bug. 'float' is not a html-atttribute but part of a html-attribute-value. The regexp you are using is based on detecting and ignoring html-attributes and uses the trailing '=' to detect and ignore these. To handle detecting html-attribute-value you will need a different regexp because there is no trailing '='. Please show some examples of the html code where 'float' must be replaced. fraizor and TheXman 2 Link to comment Share on other sites More sharing options...
fraizor Posted July 24, 2023 Author Share Posted July 24, 2023 4 minutes ago, OJBakker said: It's not a bug. 'float' is not a html-atttribute but part of a html-attribute-value. The regexp you are using is based on detecting and ignoring html-attributes and uses the trailing '=' to detect and ignore these. To handle detecting html-attribute-value you will need a different regexp because there is no trailing '='. Please show some examples of the html code where 'float' must be replaced. Thank you for your response after trying out for 2 hours with regex i came up with this:https://regex101.com/ what do you think ? AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
TheXman Posted July 24, 2023 Share Posted July 24, 2023 3 minutes ago, fraizor said: after trying out for 2 hours with regex i came up with this:https://regex101.com/ Are you trying to say that you came up with nothing or did you paste the wrong link? fraizor, Werty and Andreik 3 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...
fraizor Posted July 24, 2023 Author Share Posted July 24, 2023 5 minutes ago, TheXman said: Are you trying to say that you came up with nothing or did you paste the wrong link? sorry wrong link https://regex101.com/r/EC8Ob4/1 AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
TheXman Posted July 24, 2023 Share Posted July 24, 2023 (edited) Solely based on the HTML samples that you have supplied, the search text is always immediately preceded by a ">". If that will always be the case, then the following regular expression might work for you. If it can have zero or more spaces after the ">" but before the search text, then you can easily make that modification to the pattern. Func _HTML_ReplaceAllText($sSource, $sSearchText, $sReplaceText) Return StringRegExpReplace( _ $sSource, _ "(?i)(>)\Q" & $sSearchText & "\E", _ "$1" & $sReplaceText _ ) EndFunc https://regex101.com/r/fIGif2/1 Edited July 24, 2023 by TheXman fraizor 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...
OJBakker Posted July 24, 2023 Share Posted July 24, 2023 The following seems to work for 'Style' and 'float'. In words: search text after a tag and before the next tag, with optional spacing before/after the search text. "(?i)(<[^>]*?[^>]*?>\s*)\Q" & $sSearchText & "\E(\s*[^<]*?<)" Link to comment Share on other sites More sharing options...
fraizor Posted July 24, 2023 Author Share Posted July 24, 2023 Thank you all for your great help, all good now 👍 AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! 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