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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:45:15+00:00 2026-05-22T14:45:15+00:00

I wonder how i can exclude a substring from the result after it matches

  • 0

I wonder how i can exclude a substring from the result after it matches the pattern.
example:

<a href="?page1"><?php __('string1');?></a>
<a href="?page2"><?php __("string2");?></a>

I want to get only the strings passed as parameters to the __() function. i tried this regex:

'/__\(((\'([^\']+)\')|(\"([^\"]+)\"))/'

but that returns ‘string1’ and “string2” wrapped in single quotes and double quotations.
how can i exclude single quotes and double quotations?

  • 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-22T14:45:16+00:00Added an answer on May 22, 2026 at 2:45 pm

    Try this

    '/__\(('|")([^\1]+)\1\)/'
           ^1^  ^^2^^^
    

    You can see it online here on Regexr

    Every time when you open a round bracket you create a capturing group. So, if you don’t want it use (?:) this would define a non capturing group. I don’t use this here. I rewrote your regex a bit. In my first group I check if there are ' or " and store them into group 1. later on I use the backreference \1 to this group one, to use the correct character.

    Your result is then stored always into group 2. How you access this result depends on your used language.

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

Sidebar

Related Questions

I wonder how can i remove all string part after #. For example if
i wonder how can i schedule and automate tasks in PHP? can i? or
I wonder how can I download/save/write a file from my server to a client's
I wonder how can I make a cross domain request from a gwt application
I wonder how can I get the list of MySQL databases in PHP using
I wonder how can I export a Visual Studio C++ project to Qt? I
I am going to develop ICQ client and I just wonder where can I
Out of curiosity, I wonder what can people do with parsers, how they are
I'd like to start coding for NVIDIA 3D Vision and wonder where can I
Wonder if anyone can help me understand how to sum up the column of

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.