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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:03:13+00:00 2026-05-26T15:03:13+00:00

I’m currently writing a program that uses ; as a seperator and extracts the

  • 0

I’m currently writing a program that uses “;” as a seperator and extracts the url up until that point upon searching the content.

So it has the format:

name;surname

In searching the given arrays… I decided to go the extra mile and test for arrays without the “;” but this has confused the program – it has no idea of the “;” position anymore and this throws a spanner in the works!

Here is my code so far – many thanks in advance!

pages = 
        [
        "The first", "An;alternative;page", "Yet another page"
        ]

    u_c_pages = 
        [
        "www.cam.ac.uk;"+pages[0]
        ,
        "www.warwick.ac.uk"+pages[1]
        ,
        "www.kcl.ac.uk;"+pages[1]
        , 
        "www;"+pages[2]
        ]

    var pattern5 = prompt('5) Please enter a search term:'); 

    function url1_m1(u_c_pages,pattern)
    {

        var seperator = []; 
        var seperatorPos = [];

        if(pattern) 
        {
            for (var i = 0; i < u_c_pages.length; i++) 
                {

                    var found = true;
                    if((u_c_pages[i].indexOf(";"))<0)
                        {
                        found=false;
                        }
                    else
                        {
                        seperator[seperator.length] = i;
                        seperatorPos[seperatorPos.length] = (u_c_pages[i].indexOf("|"));
                        }
                } 
                if(seperator.length==0)
                        {
                        return("Nothing found!");
                        }
                else
                var found2 = "";
                {
                for (var j = 0; j < seperator.length; j++) 
                        {
                        if(u_c_pages[j].substring(seperatorPos[j],u_c_pages[j].length-1).toLowerCase().indexOf(pattern.toLowerCase()) >= 0)
                            {
                            found2 = (u_c_pages[j].substring(0,seperatorPos[j]));
                            break;
                            }
                        }
                return(found2)
                }
        }
        else 
        {
        // only returned when the user decides to type in nothing
            return("Nothing entered!");
        } 
    }
    alert(url1_m1(u_c_pages,pattern5));
  • 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-26T15:03:14+00:00Added an answer on May 26, 2026 at 3:03 pm

    enjoy the power of regex:

    on JSFiddle

    pages = ["The first", "An;alternative;page", "Yet another page"];
    
    u_c_pages = [
      "www.lboro.ac.uk;"+pages[0],
      "www.xyz.ac.uk;"+pages[1],
      "www.xyz.ac.uk;"+pages[1], 
      "www;"+pages[2]
    ];
    
    var pattern5 = prompt('5) Please enter a search term:');
    
    function url1_m1(u_c_pages,pattern)
    {
      // escape search pattern
      pattern = pattern.toLowerCase().replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
      pattern = new RegExp('^([^;]+);.*?' + pattern, 'i');
    
      var result = null;
    
      for(var i=0;i<u_c_pages.length;i++) {
        if((result = u_c_pages[i].match(pattern))) {
          return result[1];
        }
      }
    
      return false;
    }
    alert(url1_m1(u_c_pages,pattern5));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT

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.