Jump to content

stringregexpreplace many string in txt??


faustf
 Share

Recommended Posts

hi guys , how  is possible  replace a   some string in txt??

example :

i have  a html page  with this part of  code

<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624406.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624406.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624405.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624405.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624404.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624404.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624403.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624403.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624402.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624402.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624401.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624401.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624400.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624400.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624416.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624416.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0021.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0021.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0022.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0022.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0023.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG-20160524-WA0023.jpg">
<p style="text-align: center;"><img alt="http://pricebay.byethost5.com/eBay/3/IMG1475828624406.jpg" src="http://pricebay.byethost5.com/eBay/3/IMG1475828624406.jpg">
</p>

i want remove  all link at foto , and   replace  with  newlink

i try to do that  with

For $i = 0 To UBound($aLFoto) - 1
                MsgBox(0,'',$e&" -- "&$m)
                $sLinkJPG_in_HTML = StringRegExpReplace($sGXML_data, '(?i)<p style="text-align: center;"><img alt="(.*?)">', '<p style="text-align: center;"><img alt="http://' & $sWWW & $sGDir3 & '/' & $aLFoto[$i] & '" src="http://' & $sWWW & $sGDir3 & '/' & $aLFoto[$i] & '">', 1)
            
                ConsoleWrite($sLinkJPG_in_HTML)
            Next

but  replace only the  first  link

how  is possible  tell at  program  after change  first  not consider them and modify the second ??

thankz at all

Link to comment
Share on other sites

is  array with a list of  new foto  inside them you can  see like this

HTB1EfO.KVXXXXXaaXXXq6xXFXXXX.jpg
HTB1TMC5KVXXXXc3aXXXq6xXFXXXt.jpg
HTB19Ve5KVXXXXcFaXXXq6xXFXXXJ.jpg
HTB16qbaKVXXXXb3XVXXq6xXFXXXY.jpg
HTB1N2LlKVXXXXXsXFXXq6xXFXXXs.jpg
HTB1x9PnKVXXXXcgXpXXq6xXFXXXh.jpg
HTB1CTDuKVXXXXaZXXXXq6xXFXXX5.jpg
HTB1cxvbKVXXXXaJXVXXq6xXFXXX8.jpg
HTB1eZDgKVXXXXckXFXXq6xXFXXXz.jpg
HTB1RHnyKVXXXXXoXXXXq6xXFXXX4.jpg
HTB14a6qKVXXXXXNXpXXq6xXFXXXN.jpg
HTB1geHtKVXXXXbLXXXXq6xXFXXXL.jpg

 

Link to comment
Share on other sites

?

Local $sContent = FileRead("file.html")

Local $aPics = ["HTB1EfO.KVXXXXXaaXXXq6xXFXXXX.jpg", _
"HTB1TMC5KVXXXXc3aXXXq6xXFXXXt.jpg", _
"HTB19Ve5KVXXXXcFaXXXq6xXFXXXJ.jpg", _
"HTB16qbaKVXXXXb3XVXXq6xXFXXXY.jpg", _
"HTB1N2LlKVXXXXXsXFXXq6xXFXXXs.jpg", _
"HTB1x9PnKVXXXXcgXpXXq6xXFXXXh.jpg", _
"HTB1CTDuKVXXXXaZXXXXq6xXFXXX5.jpg", _
"HTB1cxvbKVXXXXaJXVXXq6xXFXXX8.jpg", _
"HTB1eZDgKVXXXXckXFXXq6xXFXXXz.jpg", _
"HTB1RHnyKVXXXXXoXXXXq6xXFXXX4.jpg", _
"HTB14a6qKVXXXXXNXpXXq6xXFXXXN.jpg", _
"HTB1geHtKVXXXXbLXXXXq6xXFXXXL.jpg" ]

For $i = UBound($aPics) - 1 To 0 Step -1
    $sContent = StringRegExpReplace($sContent, '<img alt="\K[^"]+', $aPics[$i], $i + 1)
Next

ConsoleWrite($sContent)

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...