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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:59:35+00:00 2026-05-11T19:59:35+00:00

I have three variations of a string: 1. view=(edit:29,30) 2. view=(edit:29,30;) 3. view=(edit:29,30;x:100;y:200) I

  • 0

I have three variations of a string:

1. view=(edit:29,30)
2. view=(edit:29,30;)
3. view=(edit:29,30;x:100;y:200)

I need a RegExp that:

  1. capture up to and including “,30”
  2. capture “x:100;y:200” – whenever there’s a semicolon after the first match;
  3. WILL NOT include leftmost semicolon in any of the groups;
  4. entire string on the right of the first semicolon and up to ‘)’ can/should be in the same group.

I came up with:

$pat = '/view=\((\w+)(:)([\d,]+)((;[^)]+){0,}|;)\)/';

Applied to ‘view=(edit:29,30;x:100;y:200)’ it yields:

Array
(
    [0] => view=(edit:29,30;x:100;y:200)
    [1] => edit
    [2] => :
    [3] => 29,30
    [4] => ;x:100;y:200
    [5] => ;x:100;y:200
)

THE QUESTION. How do I remove ‘;’ from matches [4] and [5]?

IMPORTANT. The same RegExp should work with a string when no semicolons are present, as: ‘view=(edit:29,30)’.

$pat = '/view=\((\w+)(:)([\d,]+)((;[^)]+){0,}|;)\)/';
$str = 'view=(edit:29,30;x:100;y:200)';
preg_match($pat, $str, $m);
print_r($m);

Thanks!

  • 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-11T19:59:35+00:00Added an answer on May 11, 2026 at 7:59 pm

    You don’t need to group everything. Try this regular expression:

    /view=\((\w+):([\d,]+)(?:;([^)]+)?)?\)/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have three divs in a container that I want to float over a large
I have three divs, within a content div. Container width 70%. Within that I
I have three classes that I am using and have shortened for ease of
I know that variations on this question have been asked, but I've tried all
I need a method written in Ruby which computes Variations. I have already written
I have a problem where I need to extract a query string parameter from
Have three classes User, Group and Field. Many to many relationship on User /
i have three lists with the same number of elements in each other, i
I have three separate table variables in my Function, 1 of them is not
I have three files: lib.c lib.h => They should be built as a .so

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.