|
|
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
|
|
|
|
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: regsub (and regular expressions in general) trouble. - comp.lang ...... another, until ... regular expression meaning match the end of a line ... expressions in general) trouble. - comp.lang ... regular expression meaning match the end of a line ... Parsing Log records with regular expressions - comp.lang.ruby ...... rely on regular expressions to do it instead of reading line by ... to do with line %{line.inspect}" end ... there is no regular expression which ... lang.awk Multiple line ... Using regular expressions to split a string - comp.lang.javascript ...Is there any regular expression ... split" supports regular expressions... Example: line = "Beginning & part 2 \\& still part 2 & the end ... and then look in another ... Search in *.rex files - comp.lang.rexx... filename)) > 0 then say filename end ... of grep for Win32 and use it at the command line... ... It can also search for regular expressions another major advantage. Data with "," and field sepeator is ",", How to handle this - comp ...... line, or "," anywhere on the line, or " at the end ... free grammar parser for CSV's, regular expressions ... is to take the # burden off of the regular expression ... the difference between two forms of logic and - comp.unix.shell ...The following function is another pushd. If the && were replaced by -a in the pointed line ... has powerful and efficient regular expression ... menu-driven front end to the ... gawk problem matching multiple patterns ?!? HOW-TO? - comp.lang ...... RS="start[^e]*end" Bill - Tera-thanks! that did the trick. Another ... shed any lite? > Regular expressions like "a.*b" are greedy; as the expression ... words in a line ... Could anyone give me the spice-mode.el - comp.emacsHi, All I am new to *NIX and I am thinking of writing spice code under Emacs. However, I have no idea of Emacs Lisp. Hence, I could not write a packa... find/replace line of code (with carriage return) - comp.soft-sys ...I have a large m-file in which I need to find 1 line ... carriage returns, etc.) or even better, regular expressions to work ... c2d(left(THISchar, 3)) c2x(THISchar) end A bit of ... efficiency in awk - comp.lang.awkSo to end the missionary work and answer ... doesn't support character classes in regular expressions - has limits on input line ... ve used don't complain until an undefined ... Regex Tutorial - Start and End of String or Line AnchorsEasily create and understand regular expressions today. ... Using ^ and $ as Start of Line and End of Line Anchors ... Another Inside Look. Earlier I mentioned that ^\d*$ ... Matching an expression from a group of characters until the end of ...... after the flag and goes till end of line lines of text after second flag NFE=And this is another flag more lines of text after third flag Regular Expression 7/23/2012 4:06:01 AM
|
|
|
|
|
|
|
|
|