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

  • Home
  • SEARCH
  • 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 9171131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:07:17+00:00 2026-06-17T16:07:17+00:00

I got my original regular expression to work, and I figured I could get

  • 0

I got my original regular expression to work, and I figured I could get this one working because it’s very similar; however, I cannot.

This code is being used for a template system where links are replaced by javascript or HTML depending on whether JS is enabled on the user’s browser.

An example string would look like this:
help{:footerlink}{::helpFooter}

“help” would be the text displayed in the link itself.
“footerLink” is the CSS class that should be applied to the link
“helpFooter” is the CSS id that should be applied to the link

Here is the code I am trying to use:

$string = 'help{:footerlink}{::helpFooter}';
$classIDExp = '/([a-z0-9]+)\{:([a-z0-9]+)\}\{::([a-z0-9]+)\}/i';

$display = preg_replace($idexp, "$1", $string);
$class = preg_replace($idexp, "$2", $string);
$cssID = preg_replace($idexp, "$3", $string);

$curLink = 'Display Text: ' . $display . '<br />' .
           'Class: ' . $class . '<br />CSS ID: ' . $cssID;

echo $curLink;

This code outputs:

Display Text: help{:footerlink}{::helpFooter}
Class: help{:footerlink}{::helpFooter}
CSS ID: help{:footerlink}{::helpFooter}

The proper output would be:

Display Text: help
Class: footerlink
CSS ID: helpFooter

The link ID is retrieved just fine, but the display text, css class, and css ID can’t be found. I tried escaping the colons (:) as well, but it still shows the same output.

Any help is greatly appreciated, because as I said before, I am far from an expert on regular expressions. 🙁

  • 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-17T16:07:17+00:00Added an answer on June 17, 2026 at 4:07 pm
    if (preg_match($classIDExp, $string, $match)) {
      $display = $match[1];
      $class = $match[2];
      $cssID = $match[3];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran Perl::Critic on one of my scripts, and got this message: Regular expression
I got the JSON from apple like this { original-purchase-date-pst = 2012-06-28 02:46:02 America/Los_Angeles;
got a problem, can't get my head around this jquery and would appreciate your
I've got a variable going like this(in the original list there no whitespace): http://www.iso.org/iso/list-en1-semic-3.txt
OK my original post: Url.Action is throwing error CS1026: ) expected got answered. However
I got this problem trying to get the header-bg div to always be the
Suppose we got a original query as follows: SELECT A, B, C FROM tblA
Got a programm with 2 threads. one thread is writing some stuff into the
Got this error message while trying to load view: The model item passed into
Got a question for some jQuery wizard who might stumble upon this. When I

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.