[program-l] Re: Regular Expression Question

  • From: "Ryan Stevens" <RYSteve@xxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Sun, 7 Oct 2012 12:10:29 -0400

Hi, Rick,
 
First, I believe some ticker symbols are only one letter.  For example, I'm
pretty sure Ford's symbol is just "F".  Second, in terms of ignoring case
for letters, you would use [A-Za-z].  Third, you can place your desired
string length in curly braces.  It would be written {x,y}, and x can be 0.
If you don't have an upper limit, you would write in the form {x,}.  As an
Example, if there need to be at least two letters in the symbol, your
expression would be ^[A-Za-z][A-Za-z]{1,}.  If there are one-letter symbols,
it would be ^[A-Za-z][A-Za-z]{0,}.  Finally, because there is an optional
period or dash, you could write an expression that is comprised of two
expressions, only one of which needs to be true.  The first half is for
symbols that have neither a dash nor a period, and the other half would
check for symbols with them.  It would be written along the lines of
^(?[A-Za-z][A-Za-z]{0,})(?[A-Za-z][\-\.]{1}[A-Za-z]{1,}, although I'm not
100% sure of the location of the question marks.
 
Sorry for the long-windedness, and I hope this helps.
 
Take care,
Ryan Stevens
 

  _____  

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of RicksPlace
Sent: Sunday, October 07, 2012 10:39 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Regular Expression Question


Thanks Travis, I'll give it a try likely tomorrow.
Rick USA

----- Original Message ----- 
From: Travis  <mailto:travis@xxxxxxxxxxxxxx> Roth 
To: program-l@xxxxxxxxxxxxx 
Sent: Sunday, October 07, 2012 9:35 AM
Subject: [program-l] Re: Regular Expression Question


Hello Rick,

 

The current expression would match more than one period because the
expression is not ended, e.g., the $ sign is not used to say additional
matching is not allowed.

According to your specifications (only for upper case letters) this should
work.

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

 

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of RicksPlace
Sent: Sunday, October 07, 2012 3:43 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Regular Expression Question

 

Hi Travis:

The slash was a mistake since this is a .net app.

What I am trying to do:

Ensure the first character is a letter (Case should not matter or I can
enforce upper case as i did in my test expression)

There may be no special characters in a ticker symbol like:

MSFT or KMI or PPG

Or there may be one period in a ticker symbol like:

MSFT.OB or PPG.XYZ

There can not be more than one period if there are any in the ticker.

This would be invalid MS.FT.OB as there are 2 periods as would be MS..FT or
MSFT.. two periods are not allowed only 0 or 1.

Finally there can be 0 to 1 dashes like:

MSFT-BB or even MSFT-BB.OB.

Again MS-FT-OB would be bad because of 2 dashes in the string.

No other characters are allowed in the string only letters, perhaps one
period and, or, perhaps one dash.

I couldnt get the filters to work yesterday so just checked the first
character to ensure it was a letter - that worked.

I think the [A-Z] also works but the \. allowed more than one period like:

MS..FT or MSFT..OB

Rick USA

 

 

Other related posts: