From: Raj on
Hi,

The regular expression (\d{15,16}) matches a substring in a cell. I
want to extract the remaining part of the cell ie. from the character
after the matched substring till the end of the string in the cell
using a regular expression.

Is it possible to do this?

Thanks in advance for the help.

Regards,
Raj

From: Ron Rosenfeld on
On Sat, 1 May 2010 05:39:32 -0700 (PDT), Raj <rspai9(a)gmail.com> wrote:

>Hi,
>
>The regular expression (\d{15,16}) matches a substring in a cell. I
>want to extract the remaining part of the cell ie. from the character
>after the matched substring till the end of the string in the cell
>using a regular expression.
>
>Is it possible to do this?
>
>Thanks in advance for the help.
>
>Regards,
>Raj

(\d{15,16})([\s\S]*)

will capture everything in the cell and after your "match" into Group 2




--ron
From: Lars-�ke Aspelin on
On Sat, 01 May 2010 14:47:46 -0400, Ron Rosenfeld
<ronrosenfeld(a)nospam.org> wrote:

>On Sat, 1 May 2010 05:39:32 -0700 (PDT), Raj <rspai9(a)gmail.com> wrote:
>
>>Hi,
>>
>>The regular expression (\d{15,16}) matches a substring in a cell. I
>>want to extract the remaining part of the cell ie. from the character
>>after the matched substring till the end of the string in the cell
>>using a regular expression.
>>
>>Is it possible to do this?
>>
>>Thanks in advance for the help.
>>
>>Regards,
>>Raj
>
>(\d{15,16})([\s\S]*)
>
>will capture everything in the cell and after your "match" into Group 2
>
>
>
>
>--ron

Can't [\s\S] be replaced by . like this
(\d{15,16})(.*)

Lars-�ke

From: Raj on
To clarify, the regex should return " Raffles Traders" from the string
below:

NRK2D 986123456789312 Raffles Traders

The regex (\d{15,16})([\s\S]*) is returning "986123456789312 Raffles
Traders"

Regards,
Raj



On May 2, 12:08 am, Lars-Åke Aspelin <lar...(a)REMOOVEtelia.com> wrote:
> On Sat, 01 May 2010 14:47:46 -0400, Ron Rosenfeld
>
>
>
> <ronrosenf...(a)nospam.org> wrote:
> >On Sat, 1 May 2010 05:39:32 -0700 (PDT), Raj <rsp...(a)gmail.com> wrote:
>
> >>Hi,
>
> >>The regular expression (\d{15,16}) matches a substring in a cell. I
> >>want to extract the remaining part of the cell ie. from the character
> >>after the matched substring till the end of the string in the cell
> >>using a regular expression.
>
> >>Is it possible to do this?
>
> >>Thanks in advance for the help.
>
> >>Regards,
> >>Raj
>
> >(\d{15,16})([\s\S]*)
>
> >will capture everything in the cell and after your "match" into Group 2
>
> >--ron
>
> Can't [\s\S] be replaced by . like this
> (\d{15,16})(.*)
>
> Lars-Åke

From: Ron Rosenfeld on
On Sat, 01 May 2010 21:08:01 +0200, Lars-�ke Aspelin <larske(a)REMOOVEtelia.com>
wrote:

>Can't [\s\S] be replaced by . like this
>(\d{15,16})(.*)
>
>Lars-�ke

Your suggestion will work IF and ONLY IF there are no line feeds or carriage
returns in the cell. In some flavors, there is an option to have Dot match
newline, but such does not exist in VBA (or Javascript).

If the OP, rather than wanting to extract everything to " ... the end of the
string in the cell" only wanted to extract everything to the end of the line,
and ignore anything in the cell after a newline character, then (.*) would be
appropriate.
--ron