Re: [xsl] Replace the portion of text that matches pattern: XPath versus SNOBOL

Subject: Re: [xsl] Replace the portion of text that matches pattern: XPath versus SNOBOL
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 23 Mar 2025 10:41:53 -0000
Roger,

> replace($WORD, concat('(^.*?)', 'A'), concat('$1','E'))

is making it look more complicated the it needs to be, you don't need to
use concat (you may want to build up the expression but that's a separate
issue), and it's not any special trick just a normal regex replace as used
in xpath or any text editor (or perl or python or javascript or ...)

replace($WORD, '^(.*?)A', '$1E')

I'd probably have used


replace($WORD, '^([^A]*)A', '$1E')

rather than use newfangled regex forms such as *? for non greedy match, but
that's because I learned regex for (s)ed in the 1980s :-)

David

Current Thread