f



Regular expression from end of another regular expression till end of line

Hi,

There are lines which have numerical substrings of 15 or 16 characters
length in them.

The regular expression (\d{15,16}) matches this string. I want to
extract the portion after this 15/16 character string till end of the
line. Can this be done using a regular expression?

Thanks in advance for the help.

Regards,
Raj

0
Rajendra
5/1/2010 11:31:44 AM
comp.lang.awk 3450 articles. 0 followers. Post Follow

1 Replies
1177 Views

Similar Articles

[PageSpeed] 23

On 5/1/2010 6:31 AM, Rajendra wrote:
> Hi,
>
> There are lines which have numerical substrings of 15 or 16 characters
> length in them.
>
> The regular expression (\d{15,16}) matches this string. I want to
> extract the portion after this 15/16 character string till end of the
> line. Can this be done using a regular expression?
>
> Thanks in advance for the help.
>
> Regards,
> Raj
>

Assuming that \d is some perl-ism that means [[:digit:]], and assuming your 
{15,16} range works as you describe, I'd imagine something like this would do it:

    awk '{sub(/.*[[:digit:]]{15,16}/,"")}1' file

You'll need to use an awk that supports RE intervals. In GNU awk that'd be:

    gawk --re-interval '{sub(/.*[[:digit:]]{15,16}/,"")}1' file

Regards,

     Ed.
0
Ed
5/1/2010 11:54:46 AM
Reply: