View Single Post
Old 09-30-2021, 11:27 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
One way to do it is with a loop. Something like
Code:
program:
	for i in '0,1,2,3,4,5,6,7,8,9':
		v = list_item($comments, i, '\n');
		if substr(v, 0, 19) == 'Illustration de ' then
# compute the result
			result = 'whatever';
			break
		fi
	rof
Another way is to use re() to strip out the information of interest. Something like this:
Code:
	re($comments, '(?ms)(?:^|.*\n)<p>bar(.*?)(\n|$)', '\1')
The re() function doesn't set the option to let .* match newlines which is why the flags (?ms) were added to the beginning.

The first method will be much slower but gives you more control over what happens if there isn't a match. The speed doesn't matter if you are doing the operation in search/replace or in the Action Chains plugin.
chaley is offline   Reply With Quote