const regex = /^(-|Un reportaje de|Por)/i;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(-|Un reportaje de|Por)', 'i')
const str = `por This is an example text, this text contains emails, phone numbers and other sample designed for testing purposes. To use this tool, please type a regular expression in the text-area above.
When designing regex for emails make sure you cover all possible email types like: info@breatheco.de, dragon23@gmail.com, dragon_ball@yahoo.com.us and also test for bad email formats like ramond=32@skas.com
When texting for urls you have samples like this: https://thedomain.com.ve/dir1/dir2.html, some urls don't have extensions like this http://www.thedomain.net/directory1, maybe you will find some urls with nested subdomains like http://test.www.thedomain.com.ve/directory1`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions