Regular Expression - SubString At a set point .postgreSQL

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Regular Expression - SubString At a set point .postgreSQL

Postby saddle88 » Wed Dec 15, 2010 10:52 pm

For a custom stat Im making, the string is always a set length and only digits. Im looking for a regEx that always returns for example the 3rd and 4th digit from the string. ie- 9941991842 - Returns " 41 " .

learning regular expressions just recently, thanks.
saddle88
 
Posts: 6
Joined: Wed Dec 15, 2010 10:41 pm

Re: Regular Expression - SubString At a set point .postgreSQ

Postby saddle88 » Thu Dec 16, 2010 3:09 am

\d\d(?=\d{68}$)

boom.
saddle88
 
Posts: 6
Joined: Wed Dec 15, 2010 10:41 pm

Re: Regular Expression - SubString At a set point .postgreSQ

Postby saddle88 » Thu Dec 16, 2010 6:46 am

SQL is always one step ahead...
SUBSTRING( string FROM x FOR y )
saddle88
 
Posts: 6
Joined: Wed Dec 15, 2010 10:41 pm

Re: Regular Expression - SubString At a set point .postgreSQ

Postby saddle88 » Thu Dec 16, 2010 7:07 am

saddle88 wrote:\d\d(?=\d{68}$)

boom.


and this is in jsoft and not posix, im on a roll
saddle88
 
Posts: 6
Joined: Wed Dec 15, 2010 10:41 pm

Re: Regular Expression - SubString At a set point .postgreSQ

Postby kraada » Thu Dec 16, 2010 9:57 am

I'd do things using SUBSTRING for the most part - but it sounds like you were able to work out what you needed?
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Regular Expression - SubString At a set point .postgreSQ

Postby saddle88 » Thu Dec 16, 2010 12:38 pm

I just want to know whats possible, with so little seemingly in str_ format there isnt much I dont think.

?

for example what I posted before, even if it was the correct regex flavor there's no spot to apply something for a numeric string. Is there anything beyond -edit- enum* instances and the static referencing info for charts and such that can be accessed by substring??
saddle88
 
Posts: 6
Joined: Wed Dec 15, 2010 10:41 pm

Re: Regular Expression - SubString At a set point .postgreSQ

Postby kraada » Thu Dec 16, 2010 12:54 pm

SQL is allowed in the custom column creation section so long as the resulting value is numeric. All HUD stats are calculated by looping over all hands played by a given player.

For more detail on what sort of string functions SQL has, you can see this documentation page.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 7 guests

cron