← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #265776]: Is it possible to join a multiline string using python regex in Sikuli??

 

Question #265776 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/265776

Description changed to:
In sikuli I've get a multiline string from clipboard like this...
Names = App.getClipboard();
Name =
#corazona
#Pebleo00
#cofriasd
«paflio


and I have use this regex to delete the first character
if it is not in x00-x7f hex range or is not a word, or is a digit
import re
Names = re.sub(r"(?m)^([^\x00-\x7F]+|\W|\d)", "", Names)
So now...
Names =
corazona
Pebleo00
cofriasd
paflio


I am having trouble with the second regex that convert "Names" into a kinda List (I did the regex first in .NET)
I would like to convert "Names" into...
'corazona', 'Pebleo00', 'cofriasd', 'paflio'

So then I can apply...
NamesAsList = eval(Names)
in order to get a proper List to work with

How could I do this in python? is it necessary to use regex, or there is
other way to do this in python?

This is how I did this with .Net regex
Text to find:
(.*[^$])(\r\n|\z)
Replace with:
'$1',%" "%

Thanks Advanced.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.