How to replace src="imgelink" in multiple html files


hi all,

i need replace text:   src="name.surname_file/image001.gif     with:  src="http://www.website.com/image001.gif" in multiple htm files.

my issue in the part name.surname that different in each file.

there way for manage portion of string? the * do not work as thought

i.e.

if  src="xxxxxxxxname.xxxxxxsurname_file/image001.gif"  exist replace src="http://www.website.com/image001.gif"

my script

  $old = 'src="*_file/image001.gif"'   $new = 'src="http://www.website.com/image001.gif"'   #change get-childitem folder or choice get-childitem c:\signatures\*.htm  | {$_ -is [io.fileinfo]} |   % {   (get-content $_.fullname) -replace $old, $new | set-content $_.fullname  write-host "----- working   ----------"  write-host "processed: " + $_.fullname   }

thank you


andrea gail


in regular expression, dot matches character.  + quantifier means "one or more".  ? makes "lazy" match, means "only as need match", , may or may not necessary depending on data looks like.

regex matches "greedy" means take as can. 

$string = 'abcdefg abcdefg abcdefg' $string -replace '.+defg', '123'

will return

'123'

the .+ matched way the last 'abcdefg'.

$string = 'abcdefg abcdefg abcdefg' $string -replace '.+?defg','123'

will return

'123123123'

the .+ matches as needs satisfy match. 

http://technet.microsoft.com/en-us/library/dd315294.aspx


[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607