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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:19:56+00:00 2026-05-12T19:19:56+00:00

I want to match strings like those below. abc|q:1,f:2 cba|q:1,f:awd2,t:3awd,h:gr I am using php

  • 0

I want to match strings like those below.

abc|q:1,f:2
cba|q:1,f:awd2,t:3awd,h:gr

I am using php and have tried both preg_match and preg_match_all with this expression.

/^([a-z]+)\|([a-z]+:[a-z0-9]+,?)+$/iU

This only returns the first part before the pipe, and one a:1. What am I doing wrong, why is it behaving this way and how can I make it work?

  • 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-05-12T19:19:56+00:00Added an answer on May 12, 2026 at 7:19 pm
    /^([a-z]+)\|((?:[a-z]+:[a-z0-9]+,?)+)$/iU
    

    would capture:

    • the part before the pipe
    • the part after the part

    The greedy nature of the ‘+’ quantifier make your capturing group ([a-z]+:[a-z0-9]+,?) only capture the last set of characters matching this regex.

    /(?ms)^((?:[a-z]+)\|(?:[a-z]+:[a-z0-9]+,?)+)$/iU
    

    would capture the all line.

    Note the ‘?:‘ to avoid creating any capturing group.

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

Sidebar

Related Questions

I am using Ant and I want to match strings that look like import
i want to match for all /table[number] so strings like /table[1] and /table are
One of my variable in my PHP script produce strings like: 'something/test/1' I want
I have a problem with regular expressions. I would like to match strings that
Example: Suppose in the following example I want to match strings that do not
I want to match against Strings such as AhKs & AdKs (i.e. two cards
Let's say using Javascript, I want to match a string that ends with [abcde]*
Suppose I want to match abc within the string s only if it occurs
If you have a string with special characters that you want to match with:
Say I have strings like these: bunch of other html<a href=http://domain.com/133742/The_Token_I_Want.zip more html and

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.