Created
January 13, 2015 09:00
-
-
Save scajanus/1713c1a3d3ceba3df16d to your computer and use it in GitHub Desktop.
Regex stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| line="<td>id=j_i dt133_j_idt134_j_idt188_j_idt189_uitwc_0_uitwc_0_U20</td> muotoon <td>css=[id$=U20]</td>" | |
| #pitää siis tunnistaa rivit joissa tuo id:n sisältö loppuu johonkin U-alkuiseen stringiin ja siirtää se U-osuus tuohon uuteen muotoon. | |
| m = re.search("id\=[\w_]*_(U\w*)</td>",line) | |
| try: | |
| print m.group(1) | |
| line2 = "<td>css=[id$=" | |
| line2 +=m.group(1) | |
| line2 +="]</td>" | |
| print (line2) | |
| except: | |
| print "match not found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment