开发者

javascript regex replace help!

开发者 https://www.devze.com 2023-02-08 21:32 出处:网络
my string is like this coder<coder@gmail.com> i want coder@gmail.com back any help wil开发者_运维百科l be appreciated!var rcpt = \'coder<coder@gmail.com>\';

my string is like this

coder<coder@gmail.com>

i want coder@gmail.com back

any help wil开发者_运维百科l be appreciated!


var rcpt = 'coder<coder@gmail.com>';
var addy = rcpt.match(/<([^>]*)>/)[1];
// addy = 'coder@gmail.com'


str.split("<")[1].split(">")[0];


Do you know http://regexlib.com/ ?

It's a site full of regex with a regex coach to try your regex.

Also you can replace manually like this:

str.remove( string.indexOf('<'), 0 ) 
str.remove( 0, string.indexOf('>') ) 

or something equals...


try str.replace

<script type="text/javascript">


document.write(str.replace("coder<coder@gmail.com>
", "coder@gmail.com"));

</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消