Search code examples
javascriptextractimacros

Extract special text type with imacros


i would like to get an EVAL code for extract email address from text, searching stackoverflow i found this code

var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/g;

Extract all email addresses from bulk text using jquery i would likw to know how to create an EVAL code from this function i tried this but failed,

SET !VAR1 EVAL("var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/g;")

so please help in writing this code. thanks


Solution

  • SET testString "bla bla bla [email protected] bla bla bla"
    SET email EVAL("'{{testString}}'.match(/(([^<>()[\\]\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g)[0];")
    PROMPT {{email}}