![]() ![]() Like the to_hex trick also, I sometimes use chr(card_x + 65). I was trying something impossible, finding connecting cards within a non sorted string. This makes the regularĮxpression cleanly written with single characters: Secondary test to do it, unless you can suggest an improvement to my regex below which is not too messy.įinally, the one tricky thing I did was convert the board cards to hexadecimal so that TJQK can be represented as 9abc. If I need to exclude the straight on board specifically, I will likely write a That do not have a OE4S, then I know the straight on board is not possible. If, for example, I want to look at paired boards Generally, I will pay off hands where my opponent needs the T or the 5Īs for the straight on board, I haven't specifically addressed that case either, but I am still considering it. In cases where I am facing bets with an open-ended 4-straight (OE4S) on board. I specifically ignore them because I am interested only ![]() ![]() My use for these boards is a bit more specialized, however, so I do not address the A-hi/lo cases. Yes, it is certainly more difficult, which is why I never seriously considered writing out all the conditional statements. Maybe will try again next weekend with a regular expression I ended up writing a small plpgsql function to get it right. The board can be in any order, you'll have to exclude the straight on board and the A-high or -low four straights. John whiskyjohn Posts: 248 Joined: Fri 4:12 pmīillGatesIII wrote:How do you write a regular expression for an open ended four straight? It seems a lot more difficult than the one for the four flush. Writing out all the possible permutations without regular expression lookaheads is probably a nightmare ofĬonditions that I did not want to tackle, even though it would be faster than parsing the regular expression itself. Similarly, if IĪnyway, I wrote a regular expression to match and not match open-ended 4-straights on board, in any order. The "is not null" properly returns matching patterns, but the "is null" returns nothing. I can enable logging but I don't see any useful I'm still not sure if it is possible to use that function for negation. On one of these threads I started, the regexp_matches() function was used with select. Thx! I saw that ~ and !~ were the operators, but I needed a syntactically correct example that could be used in aįilter expression. I'm interested in what you try to achieve here, do you want to share? For instance, if a sentence ended, "over the lazy dog.", the string would be split with the last word as "dog.", resulting in no matches for a test word of "dog".BillGatesIII wrote:If you want to know if a string matches a pattern, use the ~ operator.Ĭoncat(card_1, card_2, card_3, card_4, card_5) ~ 'pattern' Note: This won't match words adjacent to punctuation. Regardless, it sounds like you have one table which has a corpus of text, and another table which has specific keywords.ĭepending on the size of your corpus, the simplest way would be to split the corpus by spaces, and check the array of words for a match: select * from table_a join table_b on table_b.title = any(string_to_array(table_a.title, ' ')) Postgres has a similar to operator which is a more powerful pattern matcher, however, you're not going to find any of the more powerful regex features such as negative lookahead. Regular expressions are much more powerful, whereas like only has two reserved keywords ( % and _) to assist with pattern matching. ![]() The like operator does not match regular expressions. Hey there! Thanks for coming to r/PostgreSQL. ![]()
0 Comments
Leave a Reply. |