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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:43:32+00:00 2026-05-16T05:43:32+00:00

I have the following regular expression to find word in text and highlight them

  • 0

I have the following regular expression to find word in text and highlight them

Using the word surface for testing purposes.

/((?<=[\W])surface?(?![\w]))|((?<![\w])surface?(?=[\W]))/iu

It matches all occurences in the following text.

surface-CoP-20-70-0000-04-02_Pre-Run_Tool_Verification_Programming_and_surface_Tare surface_revC.pdf

But if i change the first occurence of surface to contain a upper case letter, it only matches the first occurence.

Surface-CoP-20-70-0000-04-02_Pre-Run_Tool_Verification_Programming_and_surface_Tare surface_revC.pdf

Or if i put an upper case letter in some of the other occurences it matches that.

Surface-CoP-20-70-0000-04-02_Pre-Run_Tool_Verification_Programming_and_Surface_Tare surface_revC.pdf

  • 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-16T05:43:33+00:00Added an answer on May 16, 2026 at 5:43 am

    I have no idea what you’re trying to achieve there, but possibly your problem is that \w will include _ (and \W will exclude it).

    Maybe try this:

    /(?<![a-z])surface(?![a-z])/iu
    

    Or this:

    /(?<=[\W_])surface(?=[\W_])/iu
    

    Otherwise, please provide more details on what exactly you do/don’t want to match.

    Update: given this information:

    surface2010 should not be matched

    In that case, I suspect you want:

    /(?<=\b|_)surface(?=\b|_)/iu
    

    (since just \b would exclude a match containing “…and_surface_Tare…” so we add the alternation with _ to include that.)

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

Sidebar

Related Questions

I'm using the following regular expression <a href=[^/] to find all links which do
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
I have been using the following regular expression in ASP.NET and Javascript: [a-zA-ZöäüÖÄÜß0-9]{1}[a-zA-ZöäüÖÄÜß0-9_.\-]{2,14}[a-zA-ZöäüÖÄÜß0-9.!]{1} Now,
Need a regular expression to find the text between the following two examples disregarding
I have the following regular expression: /(?<={index:)\d+(?=})/g I am trying to find index integer
I need a regular expression that will find me the following text: postmaster=infonl@bostik.com info=infonl@bostik.com
I'm using the following regular expression to find the exact occurrences in infinitives. Flag
What would the regular expression be to find all instances of the following; file:///F|/rah/title.txt
I have the following regular expression with which I match a few lines. Here
I have the following regular expression which is used to give me the tags

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.