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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:07:01+00:00 2026-05-31T20:07:01+00:00

Can I specify I want the preceding character to be either (NOT A DIGIT)

  • 0

Can I specify I want the preceding character to be either (NOT A DIGIT) or (BEGINNING ANCHOR)?

I’m looking for “1/2”, but I want to ignore cases like 21/22. I know I can rule out preceding or trailing digits like this:

/([^0-9])1\/2([^0-9])/

But that fails when the match happens at the beginning or end of the line. Are anchors ^ and & allowed in grouping clauses?

  • 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-31T20:07:02+00:00Added an answer on May 31, 2026 at 8:07 pm

    If you also want to match something like a1/2, you can use a negative lookbehind (provided that your regex implementation supports it):

    irb(main):015:0> 'a1/2' =~ /(?<!\d)1\/2/
    => 1
    irb(main):016:0> '11/2' =~ /(?<!\d)1\/2/
    => nil
    

    Which is “the string 1/2, not preceded by a digit”.

    If you can’t use lookbehind, you can almost literally transfer your requirements into a regex like /([^\d]|^)(1\/2)/, which is “a character that is not a digit or the beginning of the phrase, followed by the string 1/2 (second capture group)”.

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

Sidebar

Related Questions

With the svn:ignore property, is there a way I can specify what I want
How can specify expression in LIKE operator I want to select all row in
I want to make a cloning or mapping function where I can specify (once)
Using the WCF web programming model one can specify an operation contract like so:
I want to start a server which listen to a port. I can specify
When I'm adding a record in mongodb I can specify whatever keys I want
Here, I want to loop through the <detail> elements. Although I can specify the
You can specify one buffer for your file stream like that: char buf[BUFFER_SIZE]; std::ofstream
I am looking for a Java class where I can specify a set of
I have a UIView which contains many items like UIScrollView. How can I specify

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.