simple regex question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

simple regex question

French, Shelane
I have fields with values like: 010126-COMP

What I want to get is to return everything up to the first non-digit
number. In this case, I want 010126. If I get this value: 9570_INT, then I
want 9570.

Pls

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: simple regex question

Göran Törnquist-3
This should do:

[String_FindRegExp('010126-COMP', -Find='[0-9]+')]

/Göran

On 2011-11-15 20.54, French, Shelane wrote:

> I have fields with values like: 010126-COMP
>
> What I want to get is to return everything up to the first non-digit
> number. In this case, I want 010126. If I get this value: 9570_INT, then I
> want 9570.
>
> Pls
>
> #############################################################
> This message is sent to you because you are subscribed to
>    the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to:<[hidden email]>
> Send administrative queries to<[hidden email]>
>


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: simple regex question

Jolle Carlestam-3
In reply to this post by French, Shelane
(\d+?)

HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.

16 nov 2011 kl. 05:56 skrev "French, Shelane" <[hidden email]>:

> I have fields with values like: 010126-COMP
>
> What I want to get is to return everything up to the first non-digit
> number. In this case, I want 010126. If I get this value: 9570_INT, then I
> want 9570.
>
> Pls
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: simple regex question

Trevor Borgmeier
In reply to this post by French, Shelane
I'd suggest this...

string_findRegExp('010126-COMP', -Find='^\\d+');

the "^" means "begins with",
the "\d" represents any character 0-9 (the extra "\" is just for escaping)
the "+" just matches the previous pattern repeatedly until it doesn't
match. In this case it is the "\d"

The "^" would make it so the following strings would produce no match,
where without it you would still get the 010126 returned.

x010126-COM
COM-010126

If you are interested in learning regex better, I'd recommend this site:
www.regular-expressions.info

-Trevor



on 11/15/11 1:54 PM French, Shelane wrote:

> I have fields with values like: 010126-COMP
>
> What I want to get is to return everything up to the first non-digit
> number. In this case, I want 010126. If I get this value: 9570_INT, then I
> want 9570.
>
> Pls
>
> #############################################################
> This message is sent to you because you are subscribed to
>    the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to:<[hidden email]>
> Send administrative queries to<[hidden email]>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>