query with regular expression

Started by Glenn Schultzover 7 years ago3 messagesgeneral
Jump to latest
#1Glenn Schultz
glenn@bondlab.io

All,

I am writing a query to select * from where ~ '[regx] an example of the
sting that I am matching is below

FHLG16725

The first two alpha characters to match are FN, FH, GN any alpha characters
between those and the numeric don't matter as the first two alpha + numeric
will create a unique.

reading the docs I am pretty sure I need to use ~ for bracket expression

I tried '^[FN-FG-GN][0-9]' but does not seem to work. I have to admit I am
weak on regex - never quite seem to be able to get it through my coconut.

Any help would be appreciated,
Glenn

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Glenn Schultz (#1)
Re: query with regular expression

On Thursday, January 3, 2019, Glenn Schultz <glenn@bondlab.io> wrote:

All,

I am writing a query to select * from where ~ '[regx] an example of the
sting that I am matching is below

FHLG16725

The first two alpha characters to match are FN, FH, GN any alpha
characters between those and the numeric don't matter as the first two
alpha + numeric will create a unique.

reading the docs I am pretty sure I need to use ~ for bracket expression

I tried '^[FN-FG-GN][0-9]' but does not seem to work. I have to admit I
am weak on regex - never quite seem to be able to get it through my coconut.

Yeah...that’s not even close...not exactly sure what it would match but
it’s only two characters, one letter maybe and one number. You seem to
want capturing groups though so using the ~ operator isn’t going to work,
you need to use the function.

Any help would be appreciated,
Glenn

~ ‘^(FN|FH|GN)[A-Z]*[0-9]+$’

David J.

#3Glenn Schultz
glenn@bondlab.io
In reply to: David G. Johnston (#2)
Re: query with regular expression

Thanks for the tip!

On Thu, Jan 3, 2019 at 12:58 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:

Show quoted text

On Thursday, January 3, 2019, Glenn Schultz <glenn@bondlab.io> wrote:

All,

I am writing a query to select * from where ~ '[regx] an example of the
sting that I am matching is below

FHLG16725

The first two alpha characters to match are FN, FH, GN any alpha
characters between those and the numeric don't matter as the first two
alpha + numeric will create a unique.

reading the docs I am pretty sure I need to use ~ for bracket expression

I tried '^[FN-FG-GN][0-9]' but does not seem to work. I have to admit I
am weak on regex - never quite seem to be able to get it through my coconut.

Yeah...that’s not even close...not exactly sure what it would match but
it’s only two characters, one letter maybe and one number. You seem to
want capturing groups though so using the ~ operator isn’t going to work,
you need to use the function.

Any help would be appreciated,
Glenn

~ ‘^(FN|FH|GN)[A-Z]*[0-9]+$’

David J.