简体   繁体   English

正则表达式获取两个字符串之间的数据

[英]RegEx to get data between two strings

Could someone please help me with a regular expression to get match data between two strings?有人可以帮助我使用正则表达式来获取两个字符串之间的匹配数据吗?

I have data in the below format我有以下格式的数据

/* BEGIN EXAMPLE SECTION */
"One" : "1",
"Two" : "2",
/* END EXAMPLE SECTION */

I want the output to be:我希望输出是:

"One" : "1",
"Two" : "2",

I am using a gulp strip code task to strip out the comments and get the data within them.我正在使用 gulp strip 代码任务来去除注释并获取其中的数据。

The start_comment and end_comment require a regular expression, to match the starting of the comment section and the end of the comment section respectively. start_comment 和 end_comment 需要一个正则表达式,分别匹配注释部分的开头和注释部分的结尾。 The regular expression in the file is:文件中的正则表达式为:

var re = new RegExp("([\\t ]*\\/\\* ?BEGIN ANGULAR SECTION?\\*\\/)[\\s\\S]*?(\\/\\* ?END ANGULAR SECTION?\\*\\/[\\t ]*\\n?)", "g");

If all on one line, you can try this: /.*/(.*)/ You are looking for the data between the second and third Slash(/).如果都在一行,你可以试试这个: /.*/(.*)/你正在寻找第二个和第三个斜线(/)之间的数据。 The paren's give you that grouping.父母给你那个分组。

If you have multiple lines, you will need to integrate a language.如果您有多行,则需要集成一种语言。

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

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