0

I tried to find the data using regexp in multiline text. My regexp is 'Audit Policy,[A-Za-z0-9|[:space:]]+,Success and Failure'.

# query
SELECT *
  FROM docs
 WHERE content not regexp 'Audit Policy,[A-Za-z0-9|[:space:]]+,Success and Failure';

# data
'Audit Policy,Audit account logon events,No Auditing
Audit Policy,Audit account management,Success and Failure
Audit Policy,Audit logon events,No Auditing
Audit Policy,Audit object access,Success and Failure'

I think I can search the whole data included in 'Audit Policy,Audit logon events,No Auditing' when I run the below code but it's not that work. Is there a way to get that line only using SQL queries?

SQL Fiddle: http://sqlfiddle.com/#!9/8adc4b/2

My sql version is 5.7.25 / the data column type is varchar.

Bethlee
  • 825
  • 3
  • 17
  • 28
  • 1
    What is the problem statement here? What are you trying to match or extract? – Tim Biegeleisen Aug 31 '22 at 00:50
  • What do you mean by "not same data"? – Barmar Aug 31 '22 at 00:52
  • Are you trying to split up the text into lines, and return the lines that don't match the regexp? I don't think there's any easy way to do that in MySQL. The regexp is being matched against the entire string. You should normalize your data and put each line into a separate row of the table. – Barmar Aug 31 '22 at 00:55
  • @Barmar I think when I run the script, I can get contets because I run "not regexp". Thank you for your advice. It might be difficult to get what I want if I don't separate rows of the data in the table. – Bethlee Aug 31 '22 at 03:57
  • Your regex seems fine, your table only contains one row so you do not get the right output. See [this fiddle](http://sqlfiddle.com/#!9/51733f/1) – Wiktor Stribiżew Aug 31 '22 at 07:57

0 Answers0