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

  • Home
  • SEARCH
  • 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 8236823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:15:42+00:00 2026-06-07T19:15:42+00:00

I am struggling with working out a way to get a pattern match of

  • 0

I am struggling with working out a way to get a pattern match of a variable. I have tried splitting things and doing an indexOf, using match, and a switch (true) statement, all with little success. Any help would be appreciated!

currentExports = 'sec=sys,rw=badhost1.foo.com:badhost2.foo.com,root=badhost1.foo.com:badhost2.foo.com';
badExportHosts = params.badExportHosts.split(':');
for (badHost = 0; badHost < badExportHosts.length; badHost++) {
    if (!currentExports.match(/badExportHosts[badHost]/g)) {
        printf('Entry ' + badExportHosts[badHost] + ' was not found in ' + currentExports + '\n');
    } else {
        printf('Entry ' + badExportHosts[badHost] + ' was found in ' + currentExports + '\n');
    }

If I enter into my form:

badhost1.foo.com:badhost2.foo.com

I unfortunately get this result:

Entry badhost1.foo.com was not found in sec=sys,rw=badhost1.foo.com:badhost2.foo.com,root=badhost1.foo.com:badhost2.foo.com
Entry badhost2.foo.com was not found in sec=sys,rw=badhost1.foo.com:badhost2.foo.com,root=badhost1.foo.com:badhost2.foo.com

How can I get this to match?

  • 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-07T19:15:43+00:00Added an answer on June 7, 2026 at 7:15 pm

    I think your intention here doesn’t seem clear enough, but, if I understood it correctly, and all you want is to check wether your “badHost” strings are contained anywhere on currentExports, you could try replacing this:

    if (!currentExports.match(/badExportHosts[badHost]/g)) {
    

    for this:

    if (currentExports.indexOf(badExportHosts[badHost]) < 0) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting/struggling to get registration and sign-up working within an active admin project. I have
I have been working with listviews and arrays, what I am struggling with is
I am currently trying to figure out a way to have an Android application
I've been struggling to get the following rewrite working ^/agatedepot/([0-9.]+)/([0-9a-zA-Z._]+)\?doc-id=([0-9a-zA-Z._\-]+) to /agateDepot.php?date=$1&filename=$2&doc-id=$3 I know
I have been struggling with a problem working in both html and php. in
I am struggling a bit to figure this one out. I'm working on an
I am attempting to get migrations working with my project using fluent migrator. But
After significant voodoo, I have finally got the scores API working. Turns out you
I am struggling to figure out the best way to pull content from an
I am custom drawing text into a custom UITableViewCell, but am struggling in working

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.