简体   繁体   English

python中的正则表达式从多行获取值

[英]Regex in python to get values from multiple lines

I have string in following format and needs regex to get address values. 我有以下格式的字符串,需要正则表达式来获取地址值。 example lines are following, 示例行如下,

var address = 'Uhartia, 64220 Gamarthe, France';
var address = 'Eaux Chaudes
Place de l\'Eglise, 64440 Laruns, France';

I need regex in Python. 我需要Python中的正则表达式。

This will get the quoted text ( in capture group 1 ) 这将得到引用的文本( 在捕获组1中

address\\s*=\\s*'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'

Expanded 展开式

 address \s* = \s* 
 '
 (                             # (1 start), Single quoted text
      [^'\\]* 
      (?: \\ [\S\s] [^'\\]* )*
 )                             # (1 end)
 ' 

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

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