Guest User

Untitled

a guest
Jul 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. (["'])(?:(?=(\?))2.)*?1
  2.  
  3. "(.*?)"
  4.  
  5. >>> import re
  6. >>> string = '"Foo Bar" "Another Value"'
  7. >>> print re.findall(r'"(.*?)"', string)
  8. ['Foo Bar', 'Another Value']
  9.  
  10. "([^"]*)"
  11.  
  12. ["'](?:(?<=")[^"\]*(?s:\.[^"\]*)*"|(?<=')[^'\]*(?s:\.[^'\]*)*')
  13.  
  14. (?=["'])(?:"[^"\]*(?:\[sS][^"\]*)*"|'[^'\]*(?:\[sS][^'\]*)*')
  15.  
  16. "[^"\]*(\(.|n)[^"\]*)*"|'[^'\]*(\(.|n)[^'\]*)*'
  17.  
  18. "([^"\]|\.|\n)*"|'([^'\]|\.|\n)*'
  19.  
  20. ("[ws]+")
  21.  
  22. (?<=(["']b))(?:(?=(\?))2.)*?(?=1)
  23.  
  24. /(["'])((?:(?!1)[^\]|(?:\\)*\[^\])*)1/
  25.  
  26. foo "string \ string" bar
  27.  
  28. foo "string1" bar "string2"
  29.  
  30. # opening quote
  31. (["'])
  32. (
  33. # repeat (non-greedy, so we don't span multiple strings)
  34. (?:
  35. # anything, except not the opening quote, and not
  36. # a backslash, which are handled separately.
  37. (?!1)[^\]
  38. |
  39. # consume any double backslash (unnecessary?)
  40. (?:\\)*
  41. |
  42. # Allow backslash to escape characters
  43. \.
  44. )*?
  45. )
  46. # same character as opening quote
  47. 1
  48.  
  49. string = "" foo bar" "loloo""
  50. print re.findall(r'"(.*?)"',string)
  51.  
  52. reg = r"""(['"])(%s)1"""
  53. if re.search(reg%(needle), haystack, re.IGNORECASE):
  54. print "winning..."
  55.  
  56. echo 'junk "Foo Bar" not empty one "" this "but this" and this neither' | sed 's/[^"]*"([^"]*)"[^"]*/>1</g'
  57.  
  58. |(['"])(.*?)1|i
  59.  
  60. preg_match_all('|(['"])(.*?)1|i', $cont, $matches);
  61.  
  62. Sub TestRegularExpression()
  63.  
  64. Dim oRE As VBScript_RegExp_55.RegExp '* Tools->References: Microsoft VBScript Regular Expressions 5.5
  65. Set oRE = New VBScript_RegExp_55.RegExp
  66.  
  67. oRE.Pattern = """([^""]*)"""
  68.  
  69.  
  70. oRE.Global = True
  71.  
  72. Dim sTest As String
  73. sTest = """Foo Bar"" ""Another Value"" something else"
  74.  
  75. Debug.Assert oRE.test(sTest)
  76.  
  77. Dim oMatchCol As VBScript_RegExp_55.MatchCollection
  78. Set oMatchCol = oRE.Execute(sTest)
  79. Debug.Assert oMatchCol.Count = 2
  80.  
  81. Dim oMatch As Match
  82. For Each oMatch In oMatchCol
  83. Debug.Print oMatch.SubMatches(0)
  84.  
  85. Next oMatch
  86.  
  87. End Sub
  88.  
  89. (["'])(?:\1|.)*?1
  90.  
  91. (["'])((?:\1|.)*?)1
  92.  
  93. (['"])(?:(?!1|\).|\.)*1
  94.  
  95. (?<=(['"])b)(?:(?!1|\).|\.)*(?=1)
Add Comment
Please, Sign In to add comment