Jump to content

Eternally777

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Eternally777's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=389051:date=Jun 28 2006, 08:13 PM:name=Uranium-235)--][div class=\'quotetop\']QUOTE(Uranium-235 @ Jun 28 2006, 08:13 PM) [snapback]389051[/snapback][/div][div class=\'quotemain\'][!--quotec--] I created this expression, for validating characters for an input field (0-9,a-z,A-Z,'-','_', '@', '.') ^[A-Za-z0-9\.\-_@]+$ It works, except when I test it with an input that contains all correct characters, and a backslash (which is invalid). when I test this in regex coach with the same string, it works correctly, but when I test it in PHP, it dosen't. It sees "foobar\" as valid, and it's not. When I use other invalid characters, it catches them. [/quote] What function are you using? Regex Coach appears to be designed for Perl.
  2. I'm new at this stuff to, but I in one of my scripts I use the [i]preg_match()[/i] function in an if statement to search for a certain pattern of characters in some of my strings, so maybe it will work for you too. I'm still pretty bad with the expressions, character ranges, and quantifiers though. Sorry.
  3. You couldn't possibly know how big of a help that is. I've been spinning my wheels trying to figure this stuff out for three days, but now I'm finally making progress again! Thanks a lot!
  4. Ok, thanks, next question: In my previous post you saw that I'm trying to parse a log file made up of several hundreds of lines. Each line follows the exact format: [code] 6/25 19:30:02.640  EVENT. [/code] where "EVENT" represents a string. I asked the first question to make sure that the script only parses lines starting with a date and time. Now that that works, I need to parse the EVENT string itself for specific information. There are only a handful of different formats the EVENT string can be in, and each format has its own constants. An example of one of the formats for the EVENT string is this: [code] [PLAYERS]'s [ABILITY] hits you for [NUMBER] [TYPE] damage. [/code] Everything in brackets is variable. How would I go about finding all the lines in the log that are in that format, and putting the those variables into PHP variables?
  5. I'm trying to convert this Perl script I found into a PHP script to help teach myself PHP (I'll be the first to admit, it would probably help even more if I knew Perl). The function of the perl script is to parse a text file that's several hundred lines long and sort the information into tables. Every line closely resembles this format: [code] 6/25 19:33:14.375  [EVENT] [/code] One of the first things he does is issue the statement: [code]     # check for valid format     if (/(\d+)\/(\d+) (\d+):(\d+):(\d+).(\d+)  (.*)/)     {         # extract the data we want         my $month = $1;         my $day = $2;         my $hour = $3;         my $min = $4;         my $sec = $5;         my $message = $7; [/code] Thanks to his comments, I think I understand what he's doing here. Is there a way to do the same thing in PHP?
×
×
  • 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.