expresiones regulares javascript
var text = "este es un texto de prueba";
var regEx = /este/gi;
console.log(regEx.test(text)) // true// If you want to get ALL occurrences (g), be case insensitive (i), and use boundaries so that it isn't a word within another word (\\b):
re = new RegExp(`\\b${replaceThis}\\b`, 'gi');
// example:
let inputString = "I'm John, or johnny, but I prefer john.";
let replaceThis = "John";
let re = new RegExp(`\\b${replaceThis}\\b`, 'gi');
console.log(inputString.replace(re, "Jack")); // I'm Jack, or johnny, but I prefer Jack.
// Tests website Regular Expression against document.location (current page url)
if (/^https\:\/\/example\.com\/$/.exec(document.location)){
console.log("Look mam, I can regex!");
}
Also in JavaScript:
- redux get state without store
- number is even or odd fucntion in javascript
- string concat javascript
- s3 bucket as static website for angular
- get selected text js
- node js http request get parameters
- how to check if a number is even or odd in javascript
- js prompt
- difference between key and code in javascript
- how to use react-fontawesome
- create react element with string
- redux toolkit reducer
- js clone array
- DatabaseError [SequelizeDatabaseError]: relation does not exist
- required false jquery
- javascript ajax post send an object
- datatable dropdown toggle not working
- hiding header in a specific screen in react native
- how to take create array using jquery
- how to create react app in vs code
- last element of an array javascript
- nested arrays reactjs tables
- node command get to much time
- Getting Nan when calculate two date js