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 8940527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:03:25+00:00 2026-06-15T11:03:25+00:00

I had multiple patterns (=,<,>,!=,>=,<=) that I needs to check for random strings supplied

  • 0

I had multiple patterns (“=”,”<“,”>”,”!=”,”>=”,”<=”) that I needs to check for random strings supplied by user. I also needs to find the position of occurrence of this pattern.
User supplied string format will be like this

"Name =" 
"Age >"
"date<="

Basically, I needs to separate the field name and these patterns, so it output like.

"Name" and "=" 
"Age" and ">" 
"date" and "<=" 

Please not that there can be any number of spaces between field Name and age.

Right now, I am doing these, by first removing space and then matching for each
of patterns one by one using strpos and if matches, then I separate it by using
the position from strpos to get 2 substr.

Is there any better way to do this?

  • 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-15T11:03:27+00:00Added an answer on June 15, 2026 at 11:03 am

    If your field name can’t containt special characters, which you use for patterns, it’s not very hard. Something like this should do the trick (might need a little testing before use):

    preg_match("#([^=<>!]+)\s*([=<>!]+)#", trim($string), $matches);
    echo $matches[1] . ' and ' . $matches[2];
    

    This, however, will extract only the field name and pattern, this won’t tell you the “position” of the pattern.

    P.S. To get a position, if you need it that badly, you can then use $position = strpos($string, $matches[2]);

    And if you want to make sure user can only supply the patterns allowed, you can specify them manualy and expression will look something like this: #([^=<>!]+)\s*(=|<|>|(!=)|(>=)|(<=))#

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

Sidebar

Related Questions

When I developed for the iPhone I had multiple events on touch that could
I'm trying to recreate a solution that had multiple projects in it (only the
What I wanted to do is that I had multiple tables and/or images of
so i've had multiple problems with a tic tac toe game i'm making, but
I was writing an asynchronous logging framework, where I had multiple threads dumping data.
I'm having a scenario where I had to deploy multiple directories for different languages.
I had build a tree to represent multiple connections between pages and links. And
I had another form to upload the details of 1 product which have multiple
I had a question about Java Class Path variables. If I have multiple jars
I was wondering whether anyone had any recommendations regarding populating multiple view models on

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.