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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:16:46+00:00 2026-06-01T10:16:46+00:00

I have a lot of strings containing custom tags: hello {RT|12} world {RT|465} this

  • 0

I have a lot of strings containing custom tags:

hello {RT|12} world {RT|465} this is {RT|13243}a string with{RT|13}examples

I need a regex to filter out all numbers of tags of the form {RT|xx} with xx being a number of any possible length. Since I’m not that good with regex, I’ve been trying the following:

preg_match("/{RT|.*}/", $string, $matches)

This is now filtering out the {RT|xx}-tags, but what I need for $matches to hold is an araay(12, 456, 13243, 13). Who can help me out?

  • 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-01T10:16:47+00:00Added an answer on June 1, 2026 at 10:16 am

    @Qtax I can’t comment in your answer cause I don’t have enough rep, but I’d say he should scape the pipe, so the regex match exactly the piece of text that he wants

    preg_match_all('/{RT\|(\d+)}/', $string, $matches, PREG_PATTERN_ORDER)
    

    Edit after poster comment on @Qtax answer:
    @reveller change your regex as I posted, you have a empty string cause you’re matching the ‘{RT’ before the | and the ‘(\d+)}’ after the pipe, and since the first match don’t have a group to catch up the value it return a empty string.

    Changing as I posted you’ll match the entire text so you’ll get it only once and will have the numbers that you need.

    Its happening cause a pipe ‘|’ on regex means OR, so you’re matching a ‘{RT’ OR ‘(\d+)}’.
    To not match it twice you need to escape the pipe so the regex will match it as text.

    This site is a good place to test your regexes, you just put the text you want to test, your regex on another one and you can easily see it working.

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

Sidebar

Related Questions

I have a string containing a date which has a lot of format possibilities.
I have a collection containing a LOT of Data Transfer Objects that I need
This is my situation: I have a text file containing a lot of equal-length
How are you? I have the next task. I have a lot of strings
I have a very simple unit test that just allocates a lot of Strings:
In my opinion, Vimscript does not have a lot of features for manipulating strings.
We currently have a utilities class that handles a lot of string formatting, date
I have a string (of undertermined length) that I want to copy a lot
We have lot of object with this kind of design : Interface and several
I have a database containing Page ojects with html content. A lot of the

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.