top_left top_right
bottom_left
Next Event: Unknown | Forum Rules | QGL Website | Event Registration
openFolder AusForums.com
iconwatfolderLineopenFolder LANs
iconwatfolderLineopenFolder QGL
iconwatfolderLineopenFolder QGL Forum
Author
Topic: Regular Expression Problem
Hogfather
Posts: 880
Location: Cairns, Queensland
Hey -

I have a HUGE list of VC++ dialog IDs that I need to seperate to name and number and chuck into a excel spreadsheet, in the format below:

IDD_TRIALEXPIRED 130
IDD_ENTERREGISTRATION 131
IDD_REGISTRATION 136
IDD_GROUP_PERMISSIONS 149
IDD_LOGIN 154
IDD_JOBBOOK_DETAILS 163
IDD_JOBBOOK_TRADES 168
IDD_ESTIMATESUMMARY 173
IDD_JOBBOOK_CONTACTS 187
IDD_ORDERS 190
IDD_BROWSEODBC 191
IDD_SEARCHJOB 192
IDD_JOBBOOK_COSTING 194
IDD_VARIATIONPROPERTIES 209
IDD_PROPS_PART 211
IDD_PROPERTIES_INVOICE 212
IDD_PROPERTIES_SUBCONTRACTORSQUOTE 216
IDD_NEWSECTION 217
IDD_MAT_EQUIV 217
IDD_MODULE_PROPERTIES 218
IDD_EDITSECTIONLABOUR 219
IDD_ORDERDETAILS 220
IDD_PROCESSDELIVERY 221
IDD_SEARCHDELIVERY 222

I have a text editor (Textpad) that will allow me to do regular expression search and replace, but I'm utterly s***house at them. I'm sure there's someone here who has REs fresh in their mind who might not mind working this one out?

I need to replace (using gumby RE notation that won't work):

IDD_[A-Z]*[" "]*[1-0]* with the IDD_[A-Z]* bit, and in a seperate search, the [1-0]* bit. If you know RE's hopefully this will make sense.

Thanks heaps in advance for any help. Kind of busy on this or I would have worked a dragon, ninja, pirate or kat flame in somewhere for ya.
system
--
Khel
Posts: 11171
Location: Wynnum, Queensland
I don't really understand regex, but if the list is currently in the format you posted above, and you wan't to import into excel, couldn't you just do normal search and replace, replace all spaces with commas and import it as csv?
Hogfather
Posts: 881
Location: Cairns, Queensland
Spaces are not singular, assuming I dont stuff up the HTML it looks like this really:

IDD_TRIALEXPIRED 130
IDD_ENTERREGISTRATION 131
IDD_REGISTRATION 136
IDD_GROUP_PERMISSIONS 149
IDD_LOGIN 154
IDD_JOBBOOK_DETAILS 163
IDD_JOBBOOK_TRADES 168
IDD_ESTIMATESUMMARY 173
IDD_JOBBOOK_CONTACTS 187
IDD_ORDERS 190
IDD_BROWSEODBC 191
IDD_SEARCHJOB 192
IDD_JOBBOOK_COSTING 194
IDD_VARIATIONPROPERTIES 209
IDD_PROPS_PART 211
IDD_PROPERTIES_INVOICE 212
IDD_PROPERTIES_SUBCONTRACTORSQUOTE 216
IDD_NEWSECTION 217
IDD_MAT_EQUIV 217
IDD_MODULE_PROPERTIES 218
IDD_EDITSECTIONLABOUR 219
IDD_ORDERDETAILS 220
IDD_PROCESSDELIVERY 221
IDD_SEARCHDELIVERY 222


Grr. Anyway, theres an indeterminate amount of whitespace between the IDDs and the numbers ...

last edited by Hogfather at 12:39:59 20/Jan/06
stinky
Posts: 1414
Location: Brisbane, Queensland
IDD_SEARCHDELIVERY 222


/^(.*?)\s+(.*?)$/

$1 - IDD_SEARCHDELIVERY
$2 - 222
trog
AGN Admin
Posts: 17942
Location: Brisbane, Queensland
try /(.*)(\s+)(.*)/

The IDD_ should get matched in the first brackets and the value in the third. I think. I'm rusty on perl regexps (which I assume it uses) as I've been using PHP ones for so long.
trog
AGN Admin
Posts: 17943
Location: Brisbane, Queensland
Oh yeh, stinky's is better. I always forget the question mark in (.*?) - what is that for again, its to stop "greedy" matching (or does it force it)?
stinky
Posts: 1415
Location: Brisbane, Queensland
\s+ = whitespace
stinky
Posts: 1416
Location: Brisbane, Queensland
yeah, stops greedy. i.e. it tells it to stop when it matches the next part of the regex i.e. \s+ otherwise it would *possibly* pick up the whole string as $1
Thundercracker
Posts: 1269
Location: Brisbane, Queensland
Im no regex expert but would you use 0-9 instead of 1-0?
Hogfather
Posts: 882
Location: Cairns, Queensland
Im no regex expert but would you use 0-9 instead of 1-0?


Yeh you're right. Like I said, I suck at regex :p

Thanks for all the replies guys! Something I definetly need to dust off and play with is a bit of regexing.
trog
AGN Admin
Posts: 17947
Location: Brisbane, Queensland
http://qgl.ausforums.com/?agn=thread&id=1917484 might come in handy
infi
Posts: 2906
Location: Brisbane, Queensland
i thought this was going to be an emo thread.
Hogfather
Posts: 884
Location: Cairns, Queensland
Nice link trog!
trog
AGN Admin
Posts: 17948
Location: Brisbane, Queensland
luckily I remember every interesting thing that's ever been posted!@#
system
--
Not a new post since your last visit.
New Post Since your last visit
Back To Forum
Advertise with Us | Privacy Policy | Contact Us
© Copyright 2001-2026 AusGamers Pty Ltd. ACN 093 772 242.
Hosted by Mammoth Networks - Australian VPS Hosting
Web development by Mammoth Media.