Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Remove everything except the first six digits

I have an expression and I want to get only the style number from it. My code looks like this:

Code:
var expression = 'Style No : 479682 Color : Neutral Theme : Pearl  Size : 0.25"H, 9" + 3" L  One Side Only Lead and Nickel Compliant Freshwater Pearl Disc Beaded Anklet';



var regex4 =  /[^\d{6}]/g;



var sku = expression.replace(regex4, '');



console.log(sku);
output: 47968202593
desired output: 479682
 
Last edited:
Hey there, @makamo66.

I'm not here to help you with your code, as I have no experience working with JS. But I'm actually here to talk to you about the formatting.

@Master Yoda linked to this thread: https://codeforum.org/threads/how-to-post-your-code-into-threads.183/
In another thread of yours.

Not only that, there is also here: https://codeforum.org/help/bb-codes/
That page that I've just linked to you, tells you how to insert your code(You'll need to scroll a bit though). It will also teach you other ways of formatting your code.

Please, use these as future reference and do try to remember them. Not using BBCode to format has became an issue recently and it's now a nuisance to just ask someone to format their code.
 

New Threads

Buy us a coffee!

Back
Top Bottom