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

Postby SaintsOfTheDiamond » Tue May 08, 2007 3:12 pm

Amazinz wrote:How is the data you are parsing formatted? For instance, if there are line breaks in the string .* won't match correctly depending on the regex implementation. Could it be something like that?

I never thought of that. Throwing in a [^\n\t] (plus whatever other control characters are screwing it up) should fix that, right? :-?

EDIT: I'm assuming that one that wrapped to a new line was due to my crappy screen resolution and it isn't that way in the data file, correct? Because I don't even want to try to deal with it if a record can span multiple lines. :-S :-o
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 Amazinz » Tue May 08, 2007 3:14 pm

Try it without the wildcard like this: CARDID\-\-(5340|26|)\b

I just used that on the data you provided and it worked fine.

Edit: Scratch that. It didn't work. I'm bleary-eyed right now. I don't know what I was looking at.
Last edited by Amazinz on Tue May 08, 2007 3:19 pm, edited 1 time in total.
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 Amazinz » Tue May 08, 2007 3:16 pm

SaintsOfTheDiamond wrote:
Amazinz wrote:How is the data you are parsing formatted? For instance, if there are line breaks in the string .* won't match correctly depending on the regex implementation. Could it be something like that?

I never thought of that. Throwing in a [^\n\t] (plus whatever other control characters are screwing it up) should fix that, right? :-?


Yeah there is also a flag that can be set so that the wildcard matches line break characters. I don't know off hand how to set the flag in Perl.
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 3:20 pm

Amazinz wrote:Try it without the wildcard like this: CARDID\-\-(5340|26|)\b

I just used that on the data you provided and it worked fine.

Edit: Scratch that. It didn't work. I'm bleary-eyed right now. I don't know what I was looking at.

It did work. It pulled the same results, though.
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
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 3:21 pm

StlSluggers wrote:
Amazinz wrote:Try it without the wildcard like this: CARDID\-\-(5340|26|)\b

I just used that on the data you provided and it worked fine.

Edit: Scratch that. It didn't work. I'm bleary-eyed right now. I don't know what I was looking at.

It did work. It pulled the same results, though.

Here.. CARDID\-\-(\d+) :-D
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 Amazinz » Tue May 08, 2007 3:25 pm

StlSluggers wrote:
Amazinz wrote:Try it without the wildcard like this: CARDID\-\-(5340|26|)\b

I just used that on the data you provided and it worked fine.

Edit: Scratch that. It didn't work. I'm bleary-eyed right now. I don't know what I was looking at.

It did work. It pulled the same results, though.


What is the extra | for? Using it like this CARDID\-\-(5340|26) I pulled up one match from the data sample you provided. That seems right, no?
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 3:29 pm

Amazinz wrote:
StlSluggers wrote:
Amazinz wrote:Try it without the wildcard like this: CARDID\-\-(5340|26|)\b

I just used that on the data you provided and it worked fine.

Edit: Scratch that. It didn't work. I'm bleary-eyed right now. I don't know what I was looking at.

It did work. It pulled the same results, though.


What is the extra | for? Using it like this CARDID\-\-(5340|26) I pulled up one match from the data sample you provided. That seems right, no?

When I wrote that code, I did it in Excel. I probably just didn't format that part correctly. I'll remove it to see if it matters. Your results were correct based on what I posted.
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
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 StlSluggers » Tue May 08, 2007 3:32 pm

Holy crap. That was it. I don't believe it.

That's the only query with that extra | at the end.

It was pulling "or" everything and massively overstating the results.

Image
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
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 3:38 pm

Nice. I'm fried today as well. O:-)

(as in worn out, not drugged up)
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 3:43 pm

Amazinz wrote:Nice. I'm fried today as well. O:-)

(as in worn out, not drugged up)

Yeah, my brain feels like it just finished a max out session at the gym.

I'm beat. X-I
StlSluggers
Hall of Fame Hero
Hall of Fame Hero

User avatar
CafeholicCafe WriterMock(ing) DrafterWeb Supporter
Posts: 14716
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!

PreviousNext

Return to General Talk

Who is online

Users browsing this forum: No registered users and 3 guests

Forums Articles & Tips Sleepers Rankings Leagues


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