Anyone Know Regular Expressions? - Fantasy Baseball Cafe 2014 Fantasy Baseball Cafe
100% Deposit Bonus for Cafe Members!

Return to General Talk

Anyone Know Regular Expressions?

Moderator: Baseball Moderators

Anyone Know Regular Expressions?

Postby StlSluggers » Tue May 08, 2007 9:58 am

I have a regular expression that I think I know what it's doing:

.*CARDID\-\-(5340|26|)\b

However, my manual calculations are providing different figures.

The | is working as an "equals" and not as an "includes," right?
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
(Past Year: 10)
Joined: 24 May 2004
Home Cafe: Baseball
Location: Parking in the gov't bldg @ 7th and Pine. It's only $3.00 on game day!

Re: Anyone Know Regular Expressions?

Postby Dan Lambskin » Tue May 08, 2007 10:39 am

StlSluggers wrote:I have a regular expression that I think I know what it's doing:

.*CARDID\-\-(5340|26|)\b

However, my manual calculations are providing different figures.

The | is working as an "equals" and not as an "includes," right?


is that some new form of 1337?
Image
Dan Lambskin
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe RankerMock(ing) DrafterEagle EyeLucky Ladders ChampionPick 3 Weekly WinnerMatchup Meltdown SurvivorTrivia Time Trial Monthly Winner
Posts: 10225
Joined: 20 Mar 2005
Home Cafe: Baseball

Postby knapplc » Tue May 08, 2007 10:40 am

Ron Burgundy wrote:Look, I don't speak Spanish!!!
Keep wreves in General Talk in 2011!
knapplc
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicGolden Eagle Eye
Posts: 7870
Joined: 27 Dec 2004
Home Cafe: Football
Location: It's "ell see." ELL SEE!!!

Re: Anyone Know Regular Expressions?

Postby teddy ballgame » Tue May 08, 2007 10:41 am

Dan Lambskin wrote:
StlSluggers wrote:I have a regular expression that I think I know what it's doing:

.*CARDID\-\-(5340|26|)\b

However, my manual calculations are providing different figures.

The | is working as an "equals" and not as an "includes," right?


is that some new form of 1337?

$|-|(_)7 (_)|* |\|008!!11ONE!!

Sorry. :*)
Image
teddy ballgame
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterCafe RankerGraphics ExpertMock(ing) DrafterEagle EyeWeb SupporterPick 3 Weekly WinnerLucky Ladders Weekly Winner
Posts: 11485
Joined: 7 Feb 2006
Home Cafe: Baseball
Location: Beantown

Postby SaintsOfTheDiamond » Tue May 08, 2007 11:31 am

My regular expressions are a bit rusty, and Perl even worse, but just off the top of my head "|" means bitwise "or" doesn't it? :-?

What are you getting when you run it? What are you trying to get it to do? I'll poke around with it and see what I can come up with when I get home ... after I re-teach myself Perl first. O:-)

You do know that when you write Perl scripts only you and God know what it means today and tomorrow, only one of you knows, and it ain't you. :-b
Image
Member #4 of the Inaugural Yadier Molina Fan Club!!!
SaintsOfTheDiamond
Hall of Fame Hero
Hall of Fame Hero

Fantasy ExpertCafe WriterCafe Ranker
Posts: 6480
Joined: 6 May 2004
Home Cafe: Baseball
Location: Swiping second

Postby StlSluggers » Tue May 08, 2007 11:49 am

SaintsOfTheDiamond wrote:My regular expressions are a bit rusty, and Perl even worse, but just off the top of my head "|" means bitwise "or" doesn't it? :-?

What are you getting when you run it? What are you trying to get it to do? I'll poke around with it and see what I can come up with when I get home ... after I re-teach myself Perl first. O:-)

You do know that when you write Perl scripts only you and God know what it means today and tomorrow, only one of you knows, and it ain't you. :-b

I have a long string with a particular segment I'm interested in. Here's an example:

Advanta Platinum BusinessCard,BANK--Advanta__CARDID--14

The CARDID can be assigned to more than one card name (preceeding text), so my expression needs to identify all strings that contain CARDID--14. Just to make it fun, more than one CARDID exists for each card depending on the issuing bank, so I have to add multiple CARDIDs into one result. But fun isn't enough. The original values in the CARDID XML sheet were changed by some schmuck back in January without my permission and knowledge. They changed everything from a 4-digit value to a sequential values starting at the number 1. Of course, that means I have to write a query that can pull exactly the value CARDID--1 and not CARDID--10 or CARDID--11 and so forth. Friggin' morons...

Anyways, here's an example of a query I wrote to meet all of the above criteria:

.*CARDID\-\-(3561|3562|9|14)\b

So I don't care what comes before the CARDID portion of the string (.*). The CARDID is literal, and the \-\- portion of the string completes the CARDID-- segment of the query. That part's pretty simple. The parenthetical stuff is where I think the problem is at. This query should be pulling exactly these four values:

CARDID--3561
CARDID--3562
CARDID--9
CARDID--14

I don't want it pulling CARDID--4092 because it has a 9 in it (just as an example).

Is it working that way?
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
(Past Year: 10)
Joined: 24 May 2004
Home Cafe: Baseball
Location: Parking in the gov't bldg @ 7th and Pine. It's only $3.00 on game day!

Postby Amazinz » Tue May 08, 2007 11:49 am

The | is OR.

I'm not really sure what you mean by "equals" or "includes". That regex will match 5340 OR 26 exactly but included in the larger expression.

Edit: Yes it's working that way.
Image
Maine has a good swing for a pitcher but on anything that moves, he has no chance. And if it's a fastball, it has to be up in the zone. Basically, the pitcher has to hit his bat. - Mike Pelfrey
Amazinz
Mod in Retirement
Mod in Retirement

User avatar
CafeholicFantasy ExpertCafe WriterCafe RankerMock(ing) DrafterEagle EyeWeb SupporterPick 3 Weekly WinnerSweet 16 SurvivorLucky Ladders Weekly Winner
Posts: 18800
Joined: 16 Mar 2004
Home Cafe: Baseball
Location: in Canada, toughening up figure skaters

Postby StlSluggers » Tue May 08, 2007 11:51 am

Amazinz wrote:The | is OR.

I'm not really sure what you mean by "equals" or "includes". That regex will match 5340 OR 26 exactly but included in the larger expression.

That's what I'm shooting for. If CARDID--26 exists, I don't have to worry about it including CARDID--126, right? Do I have to worry about it including CARDID--260?
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
(Past Year: 10)
Joined: 24 May 2004
Home Cafe: Baseball
Location: Parking in the gov't bldg @ 7th and Pine. It's only $3.00 on game day!

Postby Amazinz » Tue May 08, 2007 11:53 am

StlSluggers wrote:Do I have to worry about it including CARDID--260?


You do not because of \b which is setting a boundary.

And wouldn't it be

\bCARDID\-\-(3561|3562|9|14)\b

rather than

.*CARDID\-\-(3561|3562|9|14)\b
Image
Maine has a good swing for a pitcher but on anything that moves, he has no chance. And if it's a fastball, it has to be up in the zone. Basically, the pitcher has to hit his bat. - Mike Pelfrey
Amazinz
Mod in Retirement
Mod in Retirement

User avatar
CafeholicFantasy ExpertCafe WriterCafe RankerMock(ing) DrafterEagle EyeWeb SupporterPick 3 Weekly WinnerSweet 16 SurvivorLucky Ladders Weekly Winner
Posts: 18800
Joined: 16 Mar 2004
Home Cafe: Baseball
Location: in Canada, toughening up figure skaters

Postby StlSluggers » Tue May 08, 2007 11:56 am

Amazinz wrote:
StlSluggers wrote:Do I have to worry about it including CARDID--260?


You do not because of \b which is setting a boundary.

And wouldn't it be

\bCARDID\-\-(3561|3562|9|14)\b

rather than

.*CARDID\-\-(3561|3562|9|14)\b

I didn't think I wanted to include the \b at the beginning because I thought that would essentially tell it to look for a string that began with CARDID.
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
(Past Year: 10)
Joined: 24 May 2004
Home Cafe: Baseball
Location: Parking in the gov't bldg @ 7th and Pine. It's only $3.00 on game day!

Next

Return to General Talk

Who is online

Users browsing this forum: assiquate and 4 guests

Forums Articles & Tips Sleepers Rankings Leagues


Today's Games
Friday, Aug. 1
(All times are EST, weather icons show forecast for game time)

Seattle at Baltimore
(7:05 pm)
Texas at Cleveland
(7:05 pm)
Philadelphia at Washington
(7:05 pm)
Colorado at Detroit
(7:08 pm)
LA Angels at Tampa Bay
(7:10 pm)
indoors
San Francisco at NY Mets
(7:10 pm)
Cincinnati at Miami
(7:10 pm)
indoors
NY Yankees at Boston
(7:10 pm)
Minnesota at Chi White Sox
(8:10 pm)
Toronto at Houston
(8:10 pm)
Milwaukee at St. Louis
(8:15 pm)
Kansas City at Oakland
(9:35 pm)
Pittsburgh at Arizona
(9:40 pm)
Chi Cubs at LA Dodgers
(10:10 pm)
Atlanta at San Diego
(10:10 pm)

  • Fantasy Baseball
  • Article Submissions
  • Privacy Statement
  • Site Survey 
  • Contact