There is the following text:

QR-Code:какой-то текст QR-Code:еще какой-то текст QR-Code:текст для кода QR-Code:текст для кодирования scanned 6 barcode symbols from 6 images 

you need to extend the values ​​of QR codes between the "QR Code:" and the symbol of the beginning of a new line.

I try the regular expression of type:

 QR-Code:(.*)\n 

does not work. tell me how to make it right?

  • Shouldn't slash in / n be reversed? (A typo in the most tried regular season or only in this question?) - Maxim Kamalov
  • just a typo in the question. QR-Code: (. *) \ N - r00xus
  • Do you have multiline text there? Before every QR - line feed? - shoorick
  • Yes. multiline text. before every QR-Code a new line - r00xus
  • And what language? Specify. - dlarchikov

3 answers 3

Barley Script

 #!/usr/bin/perl my $text = <<CUT; QR-Code:какой-то текст QR-Code:еще какой-то текст QR-Code:текст для кода QR-Code:текст для кодирования scanned 6 barcode symbols from 6 images CUT my @codes = $text =~ /QR-Code:(.+?)\n/mg; print join "\n", @codes; 

displays the following result:

 какой-то текст еще какой-то текст текст для кода текст для кодирования 

What you need?

  • my @codes = $ text = ~ /QR-Code :(.+?)$/mg; also works - shoorick
  • ideone.com/YoJzGy :) - Majestio

Well, for beauty) ... on Ruby :

 str = <<EOT QR-Code:какой-то текст QR-Code:еще какой-то текст QR-Code:текст для кода QR-Code:текст для кодирования scanned 6 barcode symbols from 6 images EOT puts str.scan(/QR-Code:(.*)\n/) 

    Javascript ES6

    Where do without him?)))

     var res = []; `QR-Code:какой-то текст QR-Code:еще какой-то текст QR-Code:текст для кода QR-Code:текст для кодирования scanned 6 barcode symbols from 6 images` .replace(/QR-Code:(.*)/gmi, (m, g) => res.push(g)); console.log(res);