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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:54:40+00:00 2026-05-20T21:54:40+00:00

I feel like an idiot because I’ve spent a long time trying to find

  • 0

I feel like an idiot because I’ve spent a long time trying to find a regex that will work.

String: ~05276~^~0500~^~Turkey...

The … means that there can be an unlimited number of characters after. What I want is the first tilde delimited number without the tildes. I’m trying to pull some data from a text file, and I think that I can figure the rest out if I can understand how to do this.

Here’s my regex as it stands: /^~([\d]+)~/

This is what I’m getting:

[ '~05276~',
 '05276',
 index: 0,
 input: '~05276~^~0500~^~Turkey...' ]

When I use the g operator (/^~([\d]+)~/g), I’m only getting the ~05276~, and what I want is the 05726 (no tildes).

I’ve found a few different posts and resources, but I can’t seem to figure out why this isn’t working as I expect. Here’s what I found:

Javascript regex – how to get text between curly brackets

Is JavaScript/NodeJS capable of this?

Edit:

Here’s my code:

lineReader.eachLine(file, function (line) {
    var entry = {};

    entry.id = line.match(/^~([\d]+)~/);

    console.log(entry);
});

lineReader is working properly and returns a line like in my example string above.

  • 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-20T21:54:41+00:00Added an answer on May 20, 2026 at 9:54 pm

    You’r regex is (almost) fine, but you’re probably not using it right. Here’s what I’d do if I wanted an array of the numbers:

     var array = [];
     yourString.replace(/~(\d+)~/g, function(_, n) { array.push(n); });
    

    What you really don’t need is that leading “^” anchor.

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

Sidebar

Related Questions

I feel like an idiot, because i fight with something, that should be very
I feel like a complete idiot, for the last 5 hours at work I'm
Feel like an idiot :) Why does this not work? switch (sortCol) { case:
Um - I feel like an idiot, but.... ruby -e '3+5' Outputs nothing (Windows
I am not an idiot, but header files make me feel like one sometimes.
I feel like I'm missing something obvious, but I can't work out why my
I feel like I'm re-inventing the wheel, and that there is a good chance
Once again, GCC is making me feel like an idiot for having trouble with
I feel like an idiot for even asking this but does anyone have any
Ok, so I feel like a complete idiot asking this, but I've been looking

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.