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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:41:12+00:00 2026-06-11T15:41:12+00:00

Say I have an array of items I want to split on (this is

  • 0

Say I have an array of items I want to split on (this is for a page ).

I’m trying to ‘intelligently’ extract out a title, but only the relevant part.

I also dont want leading/trailing spaces.

I’m not quite sure how to go about doing this though.. without putting a bunch of loops inside of other loops.

function cleanTitle(title) {
    // Extract up to first delimiter
    var delims = ['|','·','-',':'];
} 

I am using jquery.

I also put the delims array in order of what I feel is most important. Instead of searching the entire title for the first array item before moving on to the next, I think it should do the entire string one letter at a time… each letter of the string it will check if its contained within that array. If not, it moves on. I know a lot of urls might contain even 3 out of all 4 of these, and then it wouldnt really work well otherwise.

  • 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-11T15:41:13+00:00Added an answer on June 11, 2026 at 3:41 pm

    You can use a regex to do the work for you:

    var str = "This is a title-And the rest of the string";
    var title;
    var matchChar = str.match(/^(.*?)[|·\-:]/);
    if (matchChar) {
        title = matchChar[1];   // "This is a title"
    } else {
        title = str;
    }
    

    Working demo: http://jsfiddle.net/jfriend00/kxVMB/

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

Sidebar

Related Questions

Say I have an array of table DDL queries and I want to get
Say I have an array of arbitrary size holding single characters. I want to
Say I have an array like this: [white, red, blue, red, white, green, red,
Say we have the following array of instantiated objects: SomeClass[] items = {new SomeClass(Apples,
Say, I have an array of lists, and I want to get a count
Let's say I have array like {12,23,,34,22,,,12} If there are 5 items as than
How can I remove certain items of an array? Let's say I have an
Lets say I have an array (or list) of items A[] = [a,b,c,d,e] If
Say we have array of arrays: tree_limbs = Array.new tree_limbs << %w(1 2 3
Let's say I have array of bytes: byte[] arr = new byte[] { 0,

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.