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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:55:20+00:00 2026-05-14T04:55:20+00:00

Currently we’re using javascript new RegExp(‘#[^,#=!\s][^,#=!\s]*’) (see [1]) and it mostly works, except that

  • 0

Currently we’re using javascript new RegExp('#[^,#=!\s][^,#=!\s]*') (see [1])
and it mostly works, except that it also matches URLs with anchors like http://this.is/no#hashtag and also we’d rather avoid matching foo#bar

Some attempts have been made with look-ahead but it doesn’t seem to work, or that I just don’t get it.

With the below source text:

#public #writable #kommentarer-till-beta -- all these should be matched
Verkligen #bra jobbat! T ex #kommentarer till #artiklar och #blogginlägg, kool. -- mixed within text
http://this.is/no#hashtag -- problem
xxy#bar      -- We'd prefer not matching this one, and...
#foo=bar   =foo#bar  -- we probably shouldn't match any of those either.
#foo,bar #foo;bar #foo-bar #foo:bar   -- We're flexible on whether these get matched in part or in full

.

We’d like to get below output:

(showing $ instead of <a class=tag href=…..>…</a> for readability reasons)

$ $ $ -- all these should be matched
Verkligen $ jobbat! T ex $ till $ och $, kool. -- mixed within text
http://this.is/no$ -- problem
xxy$      -- We'd prefer not matching this one, and...
$=bar   =foo$  -- we probably shouldn't match any of those either.
$,bar $ $ $   -- We're flexible on whether these get matched in part or in full

[1] http://github.com/ether/pad/blob/master/etherpad/src/plugins/twitterStyleTags/hooks.js

  • 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-14T04:55:21+00:00Added an answer on May 14, 2026 at 4:55 am

    I believe looking for word boundaries would do the trick here (or, a lack thereof, apparently – which seems rather counterintuitive to me).

    \B#[^,#=!\s]+ doesn’t match anything on the third or fourth line. However, it DOES match the #foo in #foo=bar, and everything else covered by the $ signs in your example.

    EDIT: After a little fiddling around, \B#[^,#=!\s]+[\s,] will match everything on the first and second lines. Nothing is matched on lines 3-5, and on line 6, everything except #foo,bar is matched in full (#foo,bar only has a match on the part before the comma.

    You’ll likely want a capturing group to leave out the whitespace or comma at the end, so that’d be \B(#[^,#=!\s]+)[\s,].

    (If you really want all of the tags on line 6 to be matched in full, remove the comma from the first of the character classes.)

    Note that you might need something more in there for perfect coverage, but this at least meets your current test cases.

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

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes it is a good idea and relatively easy to… May 16, 2026 at 4:58 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure of what you're looking for exactly. But… May 16, 2026 at 4:58 pm
  • Editorial Team
    Editorial Team added an answer With Chrome 5.0.375.126 on MacOSX 10.5.8 on my Mac laptop,… May 16, 2026 at 4:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want use html5's new tag to play a wav file (currently only supported
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently I have a service that uses a UserNamePasswordValidator to authenticate the client user.
I am currently running into a problem where an element is coming back from
Currently my workflow with Emacs when I am coding in C or C++ involves
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
Currently I'm doing some unit tests which are executed from bash. Unit tests are
Currently, I am writing up a bit of a product-based CMS as my first
Currently, if I want to output a SQL script for a table in my

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.