-4

I have a string

var houseNumber = '13a';

I want to split the addition from the number so I can keep it in a other field. How can I split this value without losing the number or the addition? At the end I would like to have 2 fields with the following type:

var houseNumber = 13; //Number
var addition = 'a'; //String

There are many questions about this, but I can't find one where both values has to be saved. That's why I created a new question.

1

1 Answer 1

2

Use the following code

var string_a = "jkjkhj89898";
var x = string_a.match(/[^\d]+|\d+/g);
console.log(x)

working fiddle.

Thanks

Sign up to request clarification or add additional context in comments.

3 Comments

Please you should not answer a question that is duplicate. Soon you will earn privilege to close a question. Once you have it, please choose to close instead of answering a duplicate.
sorry i refreshed the page later, then it was marked duplicate.
When you see a basic question, there is a high possibility that this has been answered before. So you should search for these questions and if found, mark it as dupe or add a comment Possible Duplicate <link> so someone else can do it. Also there is no need for sorry. We all learn gradually. :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.