Jump to content

gregchet

New Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

gregchet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You can ignore this post. I'm going to go a completely different route with the way the matches are being done.
  2. I'm trying to do what I thought would be a simple regex replacement, but no matter what I try it doesn't seem to want to work. I'm trying to do a regex search for the below text (which is part of the $string variable): ---------- ***** Hand History for Game 1111111111 ***** 25 NL ---------- [code] $pattern = "/\*\*\*\*\* Hand History for Game ([0-9]*) \*\*\*\*\*\\n25/i"; $replacement = "test"; preg_replace($pattern, $replacement, $string) [/code] 1) As soon as I move the "25" up a line so that it's right after the last * on the previous line, and then remove the "\\n" from the regex search it works fine, which is how I know it's a newline issue. 2) As suggested by other information I've found online (including php.net), I've tried "\\n", "\\\n", and "\\\\n" in the regex search, but none of them work. Does anyone have any suggestions before I pull the rest of my hair out? :P
  3. You can ignore this post! Think I may have gotten it figured out based on some responses I got on another forum (just working out a small glitch now). [a href=\"http://phpbuilder.com/board/showthread.php?p=10731261#post10731252\" target=\"_blank\"]http://phpbuilder.com/board/showthread.php...61#post10731252[/a]
  4. PHP ARRAY/REGEX PRO NEEDED!! HEEEEELP! In short, I'm trying to re-create a Poker Stars hand history convertor I made a while back. I used to use ereg_replace on a multi-line variable of text, but there were little annoying problems that kept popping up. I decided to split the multi-line variable into an array so that each line was now its own variable, and I figure this will make the searching and replacing much more accurate. This is eventually all going to be database driven, but for this example I've turned it into an array. If I can get help on this, I'll have no problem converting it over to the database version. I'm basically trying to take a list of predefined REGEX rules (and their replacements), and then if these rules much the individual lines in the newly created array, replace them (so every rule should be checked against every line, and replaced if it matches). I must be missing something here, possibly due to the fact that I've been sleep deprived for quite some time now :P (but no, not because of this convertor, hehe) If any pros wanna help me out with this, it would be GREATLY appreciated. <?php // This is an include that I use within another file, and the "$new_hand" variable is already populated with a multi-line block of text $rule[0] = "PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\)"; $rule_replacement[0] = "--------------------<BR><b>Hand Convertor v1.0 -- Poker Stars Tournament</b><BR><BR><b>NL Texas Hold'em, Freeroll - Level \\3</b> (\\4/\\5)<BR><BR><b>Tournament </b>#\\2, <b>Game </b>#\\1, "; $rule[1] = "TESTER PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\)"; $rule_replacement[1] = "TESTER --------------------<BR><b> Hand Convertor v1.0 -- Poker Stars Tournament</b><BR><BR><b>NL Texas Hold'em, Freeroll - Level \\3</b> (\\4/\\5)<BR><BR><b>Tournament </b>#\\2, <b>Game </b>#\\1, "; // Split the multi-line variable into an array so that each line is now its own variable $hand_test = split("\n", $new_hand); $rule_count = count($rule); foreach($hand_test as $ht) { $count = 0; while ($count <= $rule_count) { $skibble[$count] = eregi_replace($rule[$count], $rule_replacement[$count], $ht); $count++; } } ?> At this point I'd like the "$skibble" variable to contain the old "$new_hand" information, except with the replaced, formatted text. I'm sure I'm going to be incredibly embarassed when I see what I've done wrong here.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.