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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:04:29+00:00 2026-05-26T00:04:29+00:00

I am trying to match the following text (anywhere in the string) where string

  • 0

I am trying to match the following text (anywhere in the string) where string can be anything between A and ;

Astring;

However I don’t want to match the following

aAstring;
AAstring;

The expression (?<![A|a])A.*?; works ok for aAstring; but not for AAstring;

It seems that the lookaround doesn’t work for the same character? I must be missing something simple here.

  • 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-26T00:04:29+00:00Added an answer on May 26, 2026 at 12:04 am

    First, that’s a lookbehind, not a lookahead. To understand what’s going on here, break down what the regex is saying:

    (?<![A|a])A #An A that is not preceded by A, a, or a literal |
    .?;         #Any number of characters followed by ;
    

    Now consider your input, AAstring:

    A       #An A that is not preceded by A (because it's at the beginning of the string)
    Astring #Some characters followed by ;
    

    So the lookbehind is working, it just doesn’t do what you think it does. I think what you want is something like this:

    ^(?![Aa]{2})A.*?;
    

    That anchors itself to the beginning of the string, so you know where the lookahead is going to look. Here’s what it means:

    ^           #Beginning of the line
    (?![Aa]{2}) #"The following string must not start with two As in a row, regardless of case"
    A.*?;       #Capital A followed by anything followed by ;
    

    You could also try

    \b(?![Aa]{2})A.*?; 
    

    if your target isn’t at the very beginning of the line.

    Note that this is actually the same as ^A(?![Aa]).*?; or \bA(?![Aa]).*?;, but the above might be easier to understand.

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

Sidebar

Related Questions

I'm trying to extract/match data from a string using regular expression but I don't
I'm trying to match the text foo between the two brackets in this following
I'm trying to match the following items in the string pcode : u followed
I'm trying to match SHA1's in generic text with a regular expression. Ideally I
I am trying to match 190 in the following ~ delimited text file GPSE~21~ADVANCED
I'm trying to create regular expression that filters from the following partial text: amd64
I've got a regular expression that I'm trying to match against the following types
I am trying to match a string in the following pattern with a regex.
I am trying to use regular expressions to match some text. The following pattern
I'm trying to remove (just replace it with ) the following String: <script type=text/javascript>

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.