Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:25:18+00:00 2026-06-16T21:25:18+00:00

I currently have the following regex to parse data. And an array of exclusions

  • 0

I currently have the following regex to parse data. And an array of “exclusions”

$userNameArray = (userName1, user Name2, User Name 3);

$re = '/^(?<timeMined>[0-9]{2}:[0-9]{2}:[0-9]{2}) # timeMined 
     \s+
     (?<userName>[\w\s]+)        # user name
     \s+(?:has\s+looted)\s+    # garbage text between name and amount
     (?<amount>\d+)              # amount
     \s+x\s+                     # multiplication symbol
     (?<item>.*?)\s*$            # item name (to end of line)
   /xmu';
preg_match_all($re, $sample, $matches, PREG_SET_ORDER);
foreach ($matches as $value){
    code
}

My code currently has an if statement that if $value['userName'] is in $userNameArray to execute part of a code, and if not, do a different part. However this would be significantly easier if I could just parse the bad users out in the regex.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:25:20+00:00Added an answer on June 16, 2026 at 9:25 pm

    While you could use a negative lookahead as in

    $re = '/^(?<timeMined>[0-9]{2}:[0-9]{2}:[0-9]{2}) # timeMined 
         \s+
         (?!user1|user2|user3)       # exclude users <--
         (?<userName>[\w\s]+)        # user name
         \s+(?:has\s+looted)\s+    # garbage text between name and amount
         (?<amount>\d+)              # amount
         \s+x\s+                     # multiplication symbol
         (?<item>.*?)\s*$            # item name (to end of line)
       /xmu';
    

    that would encode significant application logic into a regular expression. Most likely, your current solution is easier to understand, more readable, and easier to change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a regex that loops through data like the following 23:10:54 User Name
I have the following regex: foo = Regex.Replace(foo, @[^a-zA-Z0-9\s-], ); Currently, this removes Unicode
I have the following Regex (in PHP) that I am using. '/^[a-zA-Z0-9&\'\s]+$/' It currently
Currently, I have the following Python regex: r'^https?://(www.)?domain.com/?(?P<path>.*)/?$' That I'm replacing with: r'/\g<path>/' This
I have the following string that would require me to parse it via Regex
I have the following regex expression /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/ that currently matches email addresses of the
I currently have the following code : $content = <name>Manufacturer</name><value>John Deere</value><name>Year</name><value>2001</value><name>Location</name><value>NSW</value><name>Hours</name><value>6320</value>; I need to
I currently have the following regex to match a date: ([012]?\d)[\/.-]([0123]?\d)[\/.-]([012]\d{3})\b This will match,
Currently (in PHP) I have the following regex pattern: \[(.*) (.*)=(.*)\] This matches [doSomething
Currently I have following XML: <Rowsets> <Rowset> <Row> <DrilldownDepth>0</DrilldownDepth> <ScheduleWeek>---</ScheduleWeek> <ABC>---</ABC> <PQR>1500</PQR> <XYZ>15000</XYZ> <Quant>285</Quant>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.