Is there a way for me to isolate the words that conclude with a number?

After receiving information from the back-end, I am required to convert it into multiple words and store them in an array. How can I achieve this using regular expressions?

Here are the words:

Enter Room/Area^_^Area 100#_#Enter Grid^_^Grid2#_#Enter Level / Building^_^Building1#_#Enter Drawing^_^Drawing1#_#Enter Spec section^_^Spec2#_#Enter BOQ^_^BOQ1#_#

The expected result is :

["Area 100", "Grid2","Building1", "Drawing1", "Spec2", "BOQ1" ]

Essentially, I need to extract words that end with a number up to the special character ^.

Answer №1

\b[a-zA-Z0-9 ]+\d+\b

Give this a shot. Check out the demonstration.

https://regex101.com/r/wZ0iA3/6

var re = /\b[a-zA-Z0-9 ]+\d+\b/gi;
var str = 'Enter Room/Area^_^Area 100#_#Enter Grid^_^Grid2#_#Enter Level / Building^_^Building1#_#Enter Drawing^_^Drawing1#_#Enter Spec section^_^Spec2#_#Enter BOQ^_^BOQ1#_#';
var m;

while ((m = re.exec(str)) != null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
// Examine your outcome by using the m-variable.
// for instance, m[0] etc.
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display data only when the user interacts with the input field - AngularJs

I am currently working on a program that requires the input data to only show if the input field is touched once. Unfortunately, I am not getting the expected result as nothing is displayed in the span tag (and there are no errors in the console). Can some ...

Having trouble converting the JQuery result from the REST request into the correct format

Currently, I am working on making a REST request for an array of objects using JQuery. During the execution of the code within the "success" section, everything works perfectly fine - the objects in the array are converted to the correct type. However, I ...

Having trouble receiving time increments while utilizing the datetimepicker

I am using a datetime picker with jQuery and I would like to only select the time without the date. When I click on the input, I am only able to pick hours. How can I fix this? $(document).ready(function() { $.datetimepicker.setDateFormatter(&a ...

Is NextJS on-demand revalidation compatible with Next/link?

https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#on-demand-revalidation According to the NextJS documentation, it appears that on-demand cache revalidation should function properly with regular <a> tags and when t ...

The issue with the AngularJS filter seems to be arising specifically when applied to

My AngularJS filter isn't functioning properly when used with an Object. Here's the View: <input type="text" ng-model="searchKeyUser.$" placeholder="Search Keys" class="form-control"><br> <ul class="list-group"> <li cla ...

Using v-model in Vue, the first option has been chosen

Is there a way to set a default value for myselect when a user visits the site for the first time? I want the first option to be selected initially, but allow the user to change their choice if they prefer another option. Can this be achieved using v-model ...

Is there a way to compare a particular JSON value to the values in an array and determine if they are similar? If so, how can I update the JSON value with the array value

My inventory of wholesalers looks like this: const wholesalers = [ "B536 - T QUALITY LTD", ]; I also have a collection of JSON objects as shown below: { 'Preferred Wholesaler': 'T-Quality' }, { 'Preferred Wholesal ...

Tips for preventing a table from showing up while scrolling unnecessarily when utilizing a heading with the CSS position property set to 'sticky'

Currently, I am facing an issue with creating a sticky header for my table. The problem arises when the header of the table has rounded edges (top right and top left) along with a box-shadow applied to the entire table. As the user scrolls through the tabl ...

Error encountered while uploading image on django through jquery and ajax

Looking for help on posting a cropped image via Jquery and ajax. I've been trying to implement a solution from a question on cropping images using coordinates, but I'm facing issues with receiving the image on Django's end. The CSRF token an ...

The D3.js click event seems to be unresponsive

Currently, I am working with D3.js and backbone.js. My goal is to create a click event for each path element. Although I have provided an onclick event as shown below, the function does not seem to be triggered. createpath: function(nodes) { paths = ...

Freezing Columns and Rows for a Spacious Scrollable Table

After extensive effort, I have been diligently striving to create a solution that allows a table's column headers to scroll with the body horizontally and the first column to scroll with the rows vertically. While I've come across solutions that ...

Unable to locate or modify an item within an array

I have a unique way of organizing my collection, with an array inside. Here's how it looks: const postsSchema = mongoose.Schema({ posts: {type: Array}, }) Now, I want to search for a specific document within this collection. I attempted the follo ...

Different Methods of Joining Tables in SQLike

Struggling with creating a two-level JOIN in SQLike, currently stuck at the one level JOIN. The source tables are JSONs: var placesJSON=[{"id":"173","name":"England","type":"SUBCTRY"},{"id":"580","name":"Great Britain","type":"CTRY"},{"id":"821","name":" ...

Step-by-step guide on positioning an image to show at the bottom of a div

I am trying to create a div that covers 100% of the screen height, with a table at the top and white space below it for an image. However, when I add the image, it ends up directly under the table instead of at the bottom of the DIV. I have searched on G ...

"An error has occurred: `nuxt.js - $(...).slider function not found`

I have integrated jQuery into my nuxt.js project by adding it to the nuxt.config.js file as shown below: build: { plugins: [ new webpack.ProvidePlugin({ '$': 'jquery', '_': 'lodash&apo ...

"Seeking clarification on submitting forms using JQuery - a straightforward query

My goal is to trigger a form submission when the page reloads. Here's what I have so far: $('form').submit(function() { $(window).unbind("beforeunload"); }); $(window).bind("beforeunload", function() { $('#disconnectform&apo ...

Setting the row ID value after performing form editing in free jqGrid

In the table, there is a primary key with 3 columns (Grupp, Kuu, Toode), and the server returns an Id created from those columns. When the primary key column is changed in form editing, the server sends back a new row id. However, Free jqgrid does not se ...

Accessing form data using Vue on submit

I'm working on a project that involves creating a form with a single input field and saving the data to a database. The technology I am using is Vue.js. Here is the template I have designed: <form class="form-horizontal" @submit.prevent="submitBi ...

Error: Trying to use 'search' before it has been initialized causes a ReferenceError

Every time I run my code, I encounter this reference error but I can't figure out what's causing it. ReferenceError: Cannot access 'search' before initialization App C:/Users/GS66/Desktop/IN20/IFN666/week4/src/App.js:60 57 | 58 | expor ...

Hold off on processing any data until the callback function has completed its execution

When it comes to the issue of Passing data between controllers in Angular JS?, I encountered a problem where my ProductService was returning NULL because the callback function had not completed. The p.getProducts() function is being evaluated, but since t ...