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

  • Follow


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
Reply Rajendra 5/1/2010 11:31:44 AM

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
Reply Ed 5/1/2010 11:54:46 AM


1 Replies
201 Views

(page loaded in 0.028 seconds)

Similiar Articles:













7/23/2012 4:06:01 AM


Reply: