From: John Devlon on
Hi,

Does anyone have a solution for the following problem:
I would like to split a string into 2 strings by the first occurense of a
number.

Example:

"Londen street 52" into "Londen street" and "52"
"New york harbor 52 dock 2" into "New york harbor" and "dock 2"

Does anyone have a solution?

Thanx

John



__________ Informatie van ESET Smart Security, versie van database viruskenmerken 5067 (20100428) __________

Het bericht is gecontroleerd door ESET Smart Security.

http://www.eset.com




From: Andrew Morton on
John Devlon wrote:
> Does anyone have a solution for the following problem:
> I would like to split a string into 2 strings by the first occurense
> of a number.
>
> Example:
>
> "Londen street 52" into "Londen street" and "52"
> "New york harbor 52 dock 2" into "New york harbor" and "dock 2"
>

Your second example suggests that if there is more text after the number
then the number is to be omitted from the result. Is this correct?

--
Andrew


From: Saga on
Andrew brings up a goo dpoint. Your first example:

> "Londen street 52" into "Londen street" and "52"

This implies that "New york harbor 52 dock 2" should be
turned into "New york harbor" and "52 dock 2". Saga


"John Devlon" <johndevlonNON(a)SPAMMEhotmail.com> wrote in message
news:MqWBn.432$ii2.405(a)newsfe29.ams2...
> Hi,
>
> Does anyone have a solution for the following problem:
> I would like to split a string into 2 strings by the first occurense of a
> number.
>
> Example:
>
> "Londen street 52" into "Londen street" and "52"
> "New york harbor 52 dock 2" into "New york harbor" and "dock 2"
>
> Does anyone have a solution?
>
> Thanx
>
> John
>
>
>
> __________ Informatie van ESET Smart Security, versie van database
> viruskenmerken 5067 (20100428) __________
>
> Het bericht is gecontroleerd door ESET Smart Security.
>
> http://www.eset.com
>
>
>
>


From: Family Tree Mike on
On 4/28/2010 9:07 AM, John Devlon wrote:
> Hi,
>
> Does anyone have a solution for the following problem:
> I would like to split a string into 2 strings by the first occurense of a
> number.
>
> Example:
>
> "Londen street 52" into "Londen street" and "52"
> "New york harbor 52 dock 2" into "New york harbor" and "dock 2"
>
> Does anyone have a solution?
>
> Thanx
>
> John
>
>
>
> __________ Informatie van ESET Smart Security, versie van database viruskenmerken 5067 (20100428) __________
>
> Het bericht is gecontroleerd door ESET Smart Security.
>
> http://www.eset.com
>
>
>
>

Depending on your answer to the question regarding keeping the 52 in the
first example, then the following regular expression should work.

(.*?)(?:\d+)(.*)

--
Mike
From: John Devlon on
Yes, you are right, my mistake.
The second should be:
"New york harbor 52 dock 2" into "New york harbor" and "52 dock 2"

Sorry


"Andrew Morton" <akm(a)in-press.co.uk.invalid> wrote in message
news:83qrabF84dU1(a)mid.individual.net...
> John Devlon wrote:
>> Does anyone have a solution for the following problem:
>> I would like to split a string into 2 strings by the first occurense
>> of a number.
>>
>> Example:
>>
>> "Londen street 52" into "Londen street" and "52"
>> "New york harbor 52 dock 2" into "New york harbor" and "dock 2"
>>
>
> Your second example suggests that if there is more text after the number
> then the number is to be omitted from the result. Is this correct?
>
> --
> Andrew
>