vikas vikas - 3 months ago 25
Perl Question

Regex to get a combination of constant and pattern

I am working on a regex which can help me in replacing a pattern in string.

The string that I have in stream is very long and after applying the regex(Find the pattern and then replace with constant value) I have to carry forward the string into my ETL stream.

To find:
<customer attribute="any number">
like <customer attribute="1">
and replace with:
<customer>. (basically just keep "customer" and delete everything)

I am new to Regex and learning it.

Any help!!



<consumer attribute=\"1\"><birth-date>1990-07-23</birth-date> </consumer>;

my $element_name = "consumer";

my $str = "<consumer attribute=\"1\"><birth-date>1990-07-23</birth-date> </consumer>";


print $str;


<consumer><birth-date>1990-07-23</birth-date> </consumer>