Thanks sven I will check on my file. Because may be my html files are funky. On 2/11/14 21:26, Sven Van Caekenberghe wrote:
Stéph,
For me all this works and gives the same result:
'<head> -BASE- <title>Dr. Stéphane Ducasse</title> </head>' copyWithRegex: '-BASE-' matchesReplacedWith: '<p>Foo</p>'.
'foo.html' asFileReference writeStreamDo: [ :out | out << '<head> -BASE- <title>Dr. Stéphane Ducasse</title> </head>' ].
'foo.html' asFileReference contents copyWithRegex: '-BASE-' matchesReplacedWith: '<p>Foo</p>'.
Sven
On 02 Nov 2014, at 16:15, Max Leske <maxleske@gmail.com> wrote:
On 02.11.2014, at 14:59, stepharo <stepharo@free.fr> wrote:
On 2/11/14 12:37, Max Leske wrote:
On 01.11.2014, at 22:07, stepharo <stepharo@free.fr> wrote:
Hi guys
I'm doing a small variable expansion to relocate my webpage. I want to expand -base- into <base>http://sdmeta.gforge.inria.fr</base> Now it works when I test with some strings inside the image
trying "self new trying"
^ self sample copyWithRegex: '-BASE-' matchesReplacedWith: self baseString.
sample
^ '<?xml version="1.0" encoding="ISO-8859-1"?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <link rel="stylesheet" href="stef.css"/> <head> -BASE- <title>Dr. Stéphane Ducasse</title> </head>'
baseString ^ '<base>http://sdmeta.gforge.inria.fr </base>'
self new trying results
'<?xml version="1.0" encoding="ISO-8859-1"?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <link rel="stylesheet" href="stef.css"/> <head> <base>http://sdmeta.gforge.inria.fr </base> <title>Dr. Stéphane Ducasse</title> </head>'
and this is good.
Now when I work with a stream it does.
contentsOf: aFileSystemFile "self new contentsOf: (FileSystem workingDirectory / 'Books.html') " contents := aFileSystemFile readStream contents
tryingContents "self new tryings"
^ self sample copyWithRegex: '-BASE-' matchesReplacedWith: contents. Whatâs the âwrongâ output you get here? In fact I get the stream contents but the regex does not match. I suspect a problem with the encodings of the file. Do you have an idea? Stef No⦠I donât see how encoding could be a problem. Can you create a minimal working (failing) test file and post it?