leuce Posted June 10, 2015 Posted June 10, 2015 Hello everyoneI need to change this:<img class="img-inline" data-inlineattributes="@xtm-id='22019'" data-inlineid="77" data-inlinetype="G" data-inlinename="t" onmouseout="hideTooltip();" src="https://asdf/getInlineImage.serv?type=G&id=1&size=11">into this:{{{77}}}and so I use this in my script:$one = StringRegExpReplace ($one, '(<img class="img-inline" data-inlineattributes="@xtm-id=''\d+''" data-inlineid=")(\d+)(".+?">)', "{{{$2}}}")...but it doesn't match it. Where is the error?Thanks!Samuel
iamtheky Posted June 10, 2015 Posted June 10, 2015 quote issues with your double singles, here you can see, though there is probably a better fix$string = '<img class="img-inline" data-inlineattributes="@xtm-id=' & '22019' & '" data-inlineid="77" data-inlinetype="G" data-inlinename="t" onmouseout="hideTooltip();" src="https://asdf/getInlineImage.serv?type=G&id=1&size=11">' $one = StringRegExpReplace ($string, '(<img class="img-inline" data-inlineattributes="@xtm-id=' & '\d+' & '" data-inlineid=")(\d+)(".+?">)', "{{{$2}}}") msgbox(0, '' , $one) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
leuce Posted June 10, 2015 Author Posted June 10, 2015 (edited) Thanks, but I'm afraid there's something wrong with the syntax of $string in your example. As far as I know, it should be:$string = '<img class="img-inline" data-inlineattributes="@xtm-id=' & "'" & '22019' & "'" & '" data-inlineid="77" data-inlinetype="G" data-inlinename="t" onmouseout="hideTooltip();" src="https://asdf/getInlineImage.serv?type=G&id=1&size=11">'in which case your regular expression does not work. Remember, the original string is ["@xtm-id='22019'"], not ["@xtm-id=22019"].Samuel==Added: I solved it with a simple hack, namely by removing all single quotes before doing the regex. Edited June 10, 2015 by leuce
jguinch Posted June 10, 2015 Posted June 10, 2015 Maybe too late, but one way :$string = '<img class="img-inline" data-inlineattributes="@xtm-id=''22019''" data-inlineid="77" data-inlinetype="G" data-inlinename="t" onmouseout="hideTooltip();" src="https://asdf/getInlineImage.serv?type=G&id=1&size=11">' $one = StringRegExpReplace($string, ".+data-inlineid=([""'])(\d+)\1.+", "{{$2}}") ConsoleWrite($one) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
leuce Posted June 10, 2015 Author Posted June 10, 2015 Thanks, jguinch, you're right -- the simpler regex makes sense :-)
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