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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:59:39+00:00 2026-06-08T23:59:39+00:00

i work in javascript and like to check if my text has some signs.

  • 0

i work in javascript and like to check if my text has some signs. I’d like to check if my text has ( ) and & letters or it has repeating letters in it. Some examples:

test – has multiple t

tes&t – has &

test(test) – has ( and ), multiple t and twice ‘e’ letter

test&(test – has & and ( and multiple t and e

test&(&t – has multiple t, multiple & and (

tesra – this one doesnt fits any patterns

I’ve already made something like this:

if ((/(\w+)(?=\1)/g).test(str)) alert('multiple signs')

but it only counts multiple signs if they are one after another so ‘teest’ would fit pattern and test wouldnt. Can anybody help me? I never could understand all those regexp features 🙁
It can be divided in two regexp.

Thanx in advance

  • 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-08T23:59:42+00:00Added an answer on June 8, 2026 at 11:59 pm

    This should do it, though it might not be very efficient (since it is not anchored):

    (?:[&()]|(\w)[^\1]*\1)
    

    An alternative would be to simply iterate over the characters, inspect and count them:

    function contains_multiple_chars(str, extra) {
        var chars = {};
        for(var i = 0,l = str.length; i < l;i++) {
            var c = str.charAt(i);
            if(c in chars || c in extra) {
                return true;
            }
            else {
                chars[c] = 1;
            }
        }
        return false;
    }
    
    var multiple = contains_multiple_chars(str, {'(': 1, ')': 1, '&': 1});
    

    (I admit the function name does not fit very well)

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

Sidebar

Related Questions

Do .htc style behaviours still work if javascript is disabled? I'd like to use
I'd like to work out the distance between two points. No map. No javascript.
Is there something like die in JavaScript? I've tried with break, but doesn't work
I came across some javascript at work today that used jQuery to fetch two
I am looking for some code (either PHP or JavaScript) would work well to
Some background to the problem: Reverse Engineering the DOM, Javascript events & "what's going
I used to work in JavaScript a lot and one thing that really bothered
How does collision detection work in JavaScript? I can't use jQuery or gameQuery -
How does the Function Scope in JavaScript work?
I do a little bit of third party javascript work for a company where

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.