简体   繁体   English

node.js正则表达式拆分字符串以发送到另一台服务器

[英]node.js regex splitting a string to send to another server

I'm trying to split this type of string in node.js currently to send information from one server to another. 我正在尝试在node.js中拆分此类字符串,以将信息从一台服务器发送到另一台服务器。 I'm having trouble getting any regular expression to work considering I kind of stink at Regular Expressions in Node.js or any language at the moment. 考虑到我现在对Node.js或任何语言中的正则表达式有些恶心,我无法使任何正则表达式正常工作。 I'm trying to make it easier on myself without having a bunch of strings that replace or are split into an array. 我正在尝试使自己更轻松,而不必使用一堆替换或拆分为数组的字符串。 So, here's the string: 因此,这是字符串:

?name!identity@url.url

Is it possible to just get the name from this string without .replace() and .split()? 是否可以仅从该字符串中获取名称而无需.replace()和.split()?

using matching groups: 使用匹配组:

 var myString = "?name!identity@url.url"; var myRegexp = /\\?(.*?)\\!.+?/g; var match = myRegexp.exec(myString); if(match) { alert(match[1]); // name } else { alert("no match"); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM