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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:59:48+00:00 2026-06-02T20:59:48+00:00

So I’ve been working on a little project to write a syntax highlighter for

  • 0

So I’ve been working on a little project to write a syntax highlighter for a game’s scripting language. It’s all gone off without a hitch, except for one part: the numbers.

Take these lines for example

(5:42) Set database entry {healthpoints2} to the value 100.

(5:140) Move the user to position (29,40) on the map.

I want to highlight that 100 on the end, without highlighting the (5:42) or the 2 in the braces. The numbers won’t always be in the same place, and there won’t always only be one number.

I basically need a regexp to say:

“Match any numbers that aren’t anywhere between {} and don’t match the (#:#) pattern.”

I’ve been at this for a day and a half now and I’m pulling out my hair trying to figure it out. Help with this would be greatly appreciated!
I’ve already looked at regular-expressions.info, and tried playing around with RegexBuddy, but i’m just not getting it :c

Edit: By request, here’s some more lines copied right from the script editor.

(0:7) When somebody moves into position (**10** fhejwkfhwjekf **20**,

(0:20) When somebody rolls exactly **10** on **2** dice of **6** sides,

(0:31) When somebody says {...},

(3:3) within the diamond (**5**,**10**) - **20** //// **25**,

(3:14) in a line starting at (#, #) and going # more spaces northeast.

(5:10) play sound # to everyone who can see (#,#).

(5:14) move the user to (#,#) if there's nobody already there.

(5:272) set message ~msg to be the portion of message ~msg from position # to position #.

(5:302) take variable %var and add # to it.

(5:600) set database entry {...} about the user to #.

(5:601) set database entry {...} about the user named {...} to #.

  • 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-02T20:59:49+00:00Added an answer on June 2, 2026 at 8:59 pm

    You might kick yourself when you see this solution…

    Assuming this desired number will always be used in a sentence, it should always have a space preceding it.

    $pattern = '/ [0-9]+/s';
    

    If the preceding space isn’t always present, let me know and I’ll update the answer.


    Here’s the updated regex to match the 2 examples in your question:

    $pattern = '/[^:{}0-9]([0-9,]+)[^:{}0-9]/s';
    

    3nd update to account for your question revisions:

    $pattern = '/[^:{}0-9a-z#]([0-9]+[, ]?[0-9]*)[^:{}0-9a-z#]/s';
    

    So you don’t highlight the number in things like

    {update 29 testing}

    you might want to pre strip the braces, like so:

    $pattern = '/[^:{}0-9a-z#]([0-9]+[, ]?[0-9]*)[^:{}0-9a-z#]/s';
    $str = '(0:7) Hello {update 29 testing} 123 Rodger alpha charlie 99';
    $tmp_str = preg_replace('/{[^}]+}/s', '', $str);
    preg_match($pattern, $tmp_str, $matches);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.