• Skip to primary navigation
  • Skip to content
  • Skip to footer
Arshad Mehmood
  • Today I Learned
  • Portfolio
  • Contact
    1. Home
    2. /
    3. Today i learned
    4. /
    5. Javascript
    6. /
    7. Replace everything in a string before a certain point using regex
    Arshad Mehmood

    Arshad Mehmood

    Software engineer for web and mobile. M.Sc. Business Informatics, University of Mannheim.

    • Mannheim, Germany
    • My Android Apps
    • Website
    • LinkedIn
    • GitHub
    • Twitter
    • Instagram

    Replace everything in a string before a certain point using regex

    less than 1 minute read

    Replace everything in a string before a certain point using regex

    To remove/replace anything in a string to a certain point, use the following regex:

      var alphabet = "ABCDEFGHIJKLMNOPQRSTUVEXYZ";
      var replaced = alphabet.replace(/^.+M/,'');
    

    This will replace everything before M and including M.

    Stackoverflow

    Share on

    Twitter Facebook LinkedIn

    Leave a comment

    • Follow:
    • Twitter
    • GitHub
    • Instagram
    • Feed
    © 2025 Arshad Mehmood. Powered by Jekyll & Minimal Mistakes.