[program-l] Re: Regular Expression Question

  • From: "Travis Roth" <travis@xxxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Sat, 6 Oct 2012 13:56:03 -0500

Hello Rick,

 

I assume that you want the / and dot symbols to be optional if you want it
to be able to match MSFT. So:

 

^[A-Z][A-Z]*[\/\.]?

 

Note: I cannot recall if the / is a special symbol and needs to be escaped
but it doesn't hurt. If you do not escape the dot that is a regex  symbol
for any character if memory serves - which it may not.

 

I used this simulator to test the above using POSIX.

http://www.spaweditor.com/scripts/regex/index.php

 

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of RicksPlace
Sent: Saturday, October 06, 2012 1:06 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Regular Expression Question

 

Hi Travis:

I created 2 textboxes and enter the expression in one and the test string in
the other.

Not having much luck so far.

This should work from my megar understanding but fails:

^[A-Z][A-Z]*/.?

Test string:

MSFT.

This fails.

Do you see anything?

Rick USA

----- Original Message ----- 

From: Travis Roth <mailto:travis@xxxxxxxxxxxxxx>  

To: program-l@xxxxxxxxxxxxx 

Sent: Saturday, October 06, 2012 1:46 PM

Subject: [program-l] Re: Regular Expression Question

 

Yes asterisk is used for any number of letters.

 

I believe you will need to escape the period and hyphen as they both have
other meanings in regex as well.

If it can be either/or you would want  them inside of brackets also.

 

It may be helpful to find a regex simulator or write something up quick you
can just run to see what it does like make an app that pops up a message box
of the results of your match, then edit and quick rerun it until you get
what you want.

 

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of RicksPlace
Sent: Saturday, October 06, 2012 12:08 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Regular Expression Question

 

Hi: I want to edit a ticker symbol in a string all caps.

First position must be letter 

Followed by more cap letters, perhaps a dash or period then at least one
more letter.

I have this as a starter does it look even remotely correct?

^[A-Z][A-Z]/-?/.?[A-Z]

Should there be a star in the second factor to indicate there can be any
number of capital letters after the first?

Now I am remembering why I didnt use them a few years ago but I hope I can
learn this time

Thanks Rick USA

Other related posts: