Re: Regular Expression help needed
- From: "LJB" <ljbartel@xxxxxxxx>
- Date: 17 Dec 2005 08:54:52 -0800
> James Whitlow wrote:
>
> > I am not sure if this is exactly what you are looking for, but it seems to
> > work with my 6 variations.
> >
> > '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Dim oRegEx, arrTest(5), sLine
> > Set oRegEx = CreateObject("VBScript.RegExp")
> >
> > oRegEx.Pattern = "^.*(?:\b|\\P)([A-D]{1}\d{6})(?:\b|\\P).*$"
> >
> > arrTest(0) = "This is a \PA123456 test line..."
> > arrTest(1) = "%89434\PB254689\P~1@3df"
> > arrTest(2) = "%89434 D787689 ~1@3df"
> > arrTest(3) = "This is a \PA123456\P test line..."
> > arrTest(4) = "This is a \PA123456 \Ptest line..."
> > arrTest(5) = "%89434 C711689\P~1@3df"
> >
> > For Each sLine in arrTest
> > MsgBox oRegEx.Replace(sLine, "$1")
> > Next
> > '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Your test cases seem to cover the cases I expect. I will have to study
> your pattern. There are things in it I've never seen before.
>
> thank you
> LJB
Its interesting how \\P captures those characters as well as the rest
of the pattern yet \b does not capture its character. Is there a way to
specify a character in the pattern but not capture it using it only to
mark the beginning or end? Since I'm not interested in capturing \P I
think I'll regexp.replace it with a space and go back to using my old
pattern.
thanks
LJB
.
- Follow-Ups:
- Re: Regular Expression help needed
- From: James Whitlow
- Re: Regular Expression help needed
- References:
- Re: Regular Expression help needed
- From: James Whitlow
- Re: Regular Expression help needed
- From: LJB
- Re: Regular Expression help needed
- Prev by Date: Re: Converting Batch file to VBScript
- Next by Date: Re: Copy folder script (special)
- Previous by thread: Re: Regular Expression help needed
- Next by thread: Re: Regular Expression help needed
- Index(es):
Relevant Pages
|