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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:50:09+00:00 2026-06-08T18:50:09+00:00

So i have this html: <img src=images alt=alt /> alt <a href =http://google/something>alt</a> test

  • 0

So i have this html:

<img src="images" alt="alt" />
alt <a href ="http://google/something">alt</a>
test hallo world monkey
<p>alt</p>

and a dictionary containing

{alt, test, hallo, world, monkey, something}

so i need a regex or another method to replace words that are not within a A tag or a img tag
I have tryed the following regex:

(?<![a-zA-Z帿ŨÆ])alt(?![a-zA-Z帿ŨÆ])^*(?!=)$

http://rubular.com/r/p52ezGmVHO

  • 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-08T18:50:10+00:00Added an answer on June 8, 2026 at 6:50 pm

    You could use regex and do a negative lookahead and lookbehind for letters:

    (?<![a-zA-Z])keyword(?![a-zA-Z])
    

    in your example this would look like this:

    bodyText = Regex.Replace(bodyText, "(?<![a-zA-Z])" + article.headword + "(?![a-zA-Z])", "<a class=\"dic\" href=\"#\">" + article.headword + "</a>");
    

    My first intend was to do a positive search for whitespace characters, but then I thought of punctuation and stuff like this, a keyword is still a keyword if it has a .,!? at the end, right? So lookaheads and lookbehinds essentially check if something preceeding or succeeding your keyword, without replacing these, too.

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

Sidebar

Related Questions

I have HTML like this: <div> <a href=>sometext<img src=images/001.jpg /></a> <a href=>sometext<img src=images/002.jpg /></a>
I have this divs in my html <img src=images/cocina1.jpg name = main_img alt=alternate_text height=250
html- <img id=storyimg src=images/stor.jpg alt=img /> <ul class=sb_menu> <li><a href=linkpage.htm class=newslink1>Wireless Networking at Fortune
I have this HTML code multiple times one after the other: <li> <img src=path/to/my/picture.jpg
I have html like this. <td id=foo> <img src=foo.png /> <img src=foo.png /> <img
Html <input type=file name=picture value= /> <img id=preview_pic src=/images/no-image.jpg alt= height=100 width=100 /> I
HTML: <div id=media-photo> <img src=/uploads/photos/16.jpg alt= /> </div> <a href=/uploads/photos/5.jpg class=img> <img src=/uploads/photos-thumbs/5.jpg alt=
If I have this html on my page <img src=samesrc class=commentimg name=differentimg1/> How onclick
I have this: HTML: <div id=selectedsongs> <a href=# rel=1>song1></a> <a href=# rel=2>song2></a> <a href=#
HTML: <br /> <div class=UpperTitle> <img src=Images/CableSolve Logo.jpg align=absmiddle padding-right: 10px; /> CableSolve Web

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.