One Star

regex replace - backreference

Hey everybody,
I'm trying for hours (it feels so) to do a tReplace with a regular expression. The search pattern is fine, but what about the Replacement? How can I reference my search pattern? I tried almost everything: \1 @1 $1 with and without quotes.
Can anyone help me?
Thanks in advance
Tags (1)

Re: regex replace - backreference

Let's take the following input file :
there are 4 cats and 1 dog
we have 1 horse and 2 chickens
10 birds 1 cat

On each line, we want to extract the 2 numeric values and concatenate them in reverse order.
In tReplace, Advanced Settings, Advanced Mode, the Pattern is : "^.*?(\\d+).*?(\\d+).*$" and the Replace is "$2;$1"
The output of the job is :
Starting job topic2991 at 22:32 29/05/2008.
22 milliseconds
Job topic2991 ended at 22:32 29/05/2008.


Re: regex replace - backreference

For those interested in the Perl solution of this problem, still in tReplace, Advanced Settings, Advanced mode, Regexp pattern is s{^.*?(\d+).*?(\d+).*$}{$2;$1}
One Star

Re: regex replace - backreference

Thanks a lot,
I really had a mistake in the search pattern.
Best Wishes