🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #152571

[OT] regexp help needed :/

#152571
From: matija
Date: Thu, 29 Jul 2004 01:22
49 lines
3169 bytes
i know this is grossly offtopic and apologize, but since many
newsreaders use regular expressions, and i know there are some
regexp freaks/friends here, i hope someone can help me.

i'm writing a syntax highlighter in javascript, using regexp
for the whole deal. basicly, i'm working on my personal web
pages, and plan on including some code snippets in different
programming languages (for example, some dialog scripts written
in pascal, but at first some javascript, which makes this thing
a javascript javascript syntax highlighter ;)). of course,
manually inserting stuff like <span class="codeKeyword"></span>
is out of the question because it would drive me insane, so
i figured i'd better do it programatically.

it all works fine and dandy (for the current state of development,
which is about 6-8 hours of regular expression madness and manic
"f5"-ing in firefox), except for one thing:

     var x = 'foo' + 'bar';

doesn't match two different strings, just one: "'foo' + 'bar'".
that, obviously, sucks big time.

similarly,

     var y = some_function('abc') + z + 'something';

gives "'abc') + z + 'something'" as the one and only string here.

my regexp looks something like this (it's not the same because
i have another quote identifier, which i left out not to
confuse you):

     var codeStringRE = new RegExp('(\'.*\')', 'g');

so, does anyone know how to instruct the bloody thing to "stop"
at the second quote mark, giving me "'foo'" and "'bar'" in the
first example and "'abc'" and "'something'" in the second one?
i don't want to resort to manual string processing/splitting
unless i'm 101% positive that this can't be done with regexp.

thanks.


-- 
there is a cheer. the gnomes have learned a new way to say hooray.   [-shpongle]

address is scrambled - remove the superfluous "x" marks to reply
Technical Details
Message-ID: <slfwxm0rp9hv.dlg@shpongle.604>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.r-kom.de!fu-berlin.de!CARNet.hr!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <slfwxm0rp9hv.dlg@shpongle.604>
Subject: [OT] regexp help needed :/
Date: Thu, 29 Jul 2004 03:22:38 +0200
From: matija <xmkrnicx@xpublicx.xsrcex.hr>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.r-kom.de!fu-berlin.de!CARNet.hr!not-for-mail
Newsgroups: news.software.readers
Organization: 604
Lines: 49
NNTP-Posting-Host: cmung4239.cmu.carnet.hr
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: bagan.srce.hr 1091064154 2150 193.198.144.175 (29 Jul 2004 01:22:34
 GMT)
X-Complaints-To: abuse@carnet.hr
NNTP-Posting-Date: Thu, 29 Jul 2004 01:22:34 +0000 (UTC)
User-Agent: 40tude_Dialog/2.0.12.1hr (b3e0b265.508.94)
X-Afraid-Of: spiders
X-Face: "wB!^cgWZ=;
 q%#:6lkzMWJ-O*>}<FSIu#HEqp5P2E#=mTGgQ-\^YM|Vt(j_|:*GI8?,7A9Z
 mkgCj|$f)nB@*>(B14sXotbL/"G.Z0u$]5\GcxnO4')%FUE\48H!!$rCLV.`
X-Mastered: the art of pizza making
X-Searching-For: GMT soundtrack (guy sigsworth)