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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:56:04+00:00 2026-06-09T10:56:04+00:00

For example, I have this string: http://www.google.com/this_is_our_network/ I want to match against the word

  • 0

For example, I have this string: "http://www.google.com/this_is_our_network/"

I want to match against the word “work” but with no alphabetic character in the start or in the end. In the above example the regex should not return a match.

But, in this string: "http://www.google.com/work_for_us.html" the regex should come up with a match since there is no alphabetic character in the start nor in the end.

  • 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-09T10:56:06+00:00Added an answer on June 9, 2026 at 10:56 am

    Try this regex: (?<=[\W_])work(?=[\W_])

    This uses positive look-ahead and look-behind assertions to respect enclosing characters but without including them in the match.

    This regex matches work

    1. if it follows a \W character or an underscore

      AND
    2. if it is followed by a \W character or an underscore.

    \b for word boundary matching can’t be used since _ matches \w which is not wanted here.


    Further examples:

    • Matching multiple words:
      (?<=[\W_])(work|job)(?=[\W_])

    • Same as above but without creating submatches:
      (?<=[\W_])(?:work|job)(?=[\W_])

    • Also respecting line end:
      (?<=[\W_])(?:work|job)(?=[\W_]|$)


    Some useful notes regarding regex syntax:

    • \w matches all alphanumeric characters and underscore; this is equivalent to [a-zA-Z0-9_]

    • \W matches the exact opposite of \w

    • \b matches boundaries between a \w and a \W character (or vise-versa)

    • Positive look-ahead assertion:
      foo(?=bar) matches foo followed by bar, without including bar in the match.

    • Positive look-behind assertion:
      (?<=foo)bar matches bar if it follows foo, without including foo in the match.

    For further information on (python) regex syntax consider the python regex docs or the perl regex docs. Also, the web-based Python Regex Tool is handy for testing.

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

Sidebar

Related Questions

I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
Hi All I have followed the following example http://www.google.com/codesearch#search/&q=NumberFormattingTextWatcher&exact_package=android&type=cs I have CurrencyTextWatcher as a
I have an array like so: array{ [39] => src=http://www.google.com/jsapi> [111] => src=http://www.example.com/wp-content/themes/code.js [55]
I have the following so far: ^((http[s]?|ftp):\/\/)(([^.:\/\s]*)[\.]([^:\/\s]+))(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)?$ Been testing against these: https://www.google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash
For example, I have this string that could change anytime I only want the
Consider the following code: public ActionResult Index(String URLQuery = http://www.google.com) { HttpWebRequest webRequest; HttpWebResponse
Basically I have this string for example $str = 'По, своей 12' I need
I have for example this string: iCanSeeBluePeople and I need it to separate it
I have a string as const char *str = Hello, this is an example
For example, I have a string variable named str. This str has a value

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.