yasirnazir
yasirnazir

Reputation: 1155

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.

Upvotes: 0

Views: 61

Answers (1)

user557597
user557597

Reputation:

This will get the quoted text (in capture group 1)

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

Expanded

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

Upvotes: 1

Related Questions