Horje
regex replace certain string Code Example
regex replace certain string
str = str.replace(/[^a-z0-9-]/g, '');

/* Everything between the indicates what your are looking for

    / is here to delimit your pattern so you have one to start and one to end
    [] indicates the pattern your are looking for on one specific character
    ^ indicates that you want every character NOT corresponding to what follows
    a-z matches any character between 'a' and 'z' included
    0-9 matches any digit between '0' and '9' included (meaning any digit)
    - the '-' character
    g at the end is a special parameter saying that you do not want you regex to stop on the first character matching your pattern but to continue on the whole string

Then your expression is delimited by / before and after. So here you say "every character not being a letter, a digit or a '-' will be removed from the string". */




Typescript

Related
conditional (click) action angular Code Example conditional (click) action angular Code Example
Testing Objects for Properties Code Example Testing Objects for Properties Code Example
typescript array string to array literal Code Example typescript array string to array literal Code Example
react functional component typescript Code Example react functional component typescript Code Example
nuxt @use "sass:math"; Code Example nuxt @use "sass:math"; Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7