The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
[SOLVED] regex and string-parsing question
tennenrishin
Member Posts: 177 Contributor II
I hope my question comes across okay.
Suppose...
We have macros %{A} and %{P}. Where...
%{P} contains some token (say #1) which serves as a kind of place-holder/wildcard.
%{A} is some unknown string, but it matches %{P} in the sense that if we replace #1 in %{P} with some known regex (say .*) then the result matches %{A}
Question:
Is there a way to obtain that part (substring) of %{A} that matches the .* that replaced #1 in %{P}?
In other words is there a way to determine what #1 represented in %{A}?
Simplistic examples:
%{A}=abcd
%{P}=a#1d
Required output: bc
%{A}=abcde
%{P}=ab#1
Required output: cde
Further comments:
I've read up a bit on "capturing groups" in regular expressions but I can't figure out a way to access what is captured by a group and put it into another macro.
Suppose...
We have macros %{A} and %{P}. Where...
%{P} contains some token (say #1) which serves as a kind of place-holder/wildcard.
%{A} is some unknown string, but it matches %{P} in the sense that if we replace #1 in %{P} with some known regex (say .*) then the result matches %{A}
Question:
Is there a way to obtain that part (substring) of %{A} that matches the .* that replaced #1 in %{P}?
In other words is there a way to determine what #1 represented in %{A}?
Simplistic examples:
%{A}=abcd
%{P}=a#1d
Required output: bc
%{A}=abcde
%{P}=ab#1
Required output: cde
Further comments:
I've read up a bit on "capturing groups" in regular expressions but I can't figure out a way to access what is captured by a group and put it into another macro.
0
Answers
I have no idea why you want to do it with macros, but everything is possible with RapidMiner The trick is to write A to an example set first and then use the Replace operator. Please have a look at the attached process.
Best, Marius