Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #9350
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <1929900.aqSPkdTlGX@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sat, 17 Dec 2011 14:12:14 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| Subject | Re: String.replace() with regex |
| Newsgroups | comp.lang.javascript |
| References | <16483917.24.1324118524679.JavaMail.geo-discussion-forums@yqlp16> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 59 |
| NNTP-Posting-Date | 17 Dec 2011 14:12:15 CET |
| NNTP-Posting-Host | 06e5dfe2.newsspool2.arcor-online.net |
| X-Trace | DXC=nHl45987DKoFXUDVUnEXQmA9EHlD;3Ycb4Fo<]lROoRa8kF<OcfhCOkE[fcFYNkLVhDZm8W4\YJNl;?f@h5gMfbll\2B]UgGPibK0=M[3e_cOc |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:9350 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Jason C wrote:
> I have this regex, which works as expected:
>
> a = a.replace(/ itxtHarvested="(.*?)"/i, "");
>
> I modified it to this:
>
> a = a.replace(/\s*itxtHarvested="*(.*?)"*/i, "");
>
> which I thought would be the same, but would make the /s and " optional.
How can it be the same then? It would make leading white-space, and
optional in that it would allow 0 or more of them, including `"""""'.
(This is probably not what you want.)
> But, in practice, instead of just removing it, it was being converted to
> something like:
>
> 441?0?
>
> (Or maybe 530"0"; I had made several modifications using the *, and now I
> don't remember which error went where.)
No, it was not.
> Does the * not mean "0 or more times" in Javascript like it does in other
> languages?
There is no "Javascript": <http://PointedEars.de/es-matrix>
The `*' means the same in ECMAScript implementations as in other programming
languages.
> I know that a few things are different with JS (like the /s
> modifier), so I wasn't sure.
ECMAScript Regular Expressions do not natively support several PCRE
features, but you can emulate some. I have recently finished emulating
support for Unicode character property escape sequences, named subpatterns,
and the `x' modifier:
<http://pointedears.de/websvn/filedetails.php?repname=JSX&path=%2Ftrunk%2Fregexp.js>
> Or, is it just something flawed in my logic that made it not work as
> expected?
Both your logic and your question are flawed.
<http://jibbering.com/faq/#posting>
<http://catb.org/~esr/faqs/smart-questions.html#beprecise>
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String.replace() with regex Jason C <jwcarlton@gmail.com> - 2011-12-17 02:42 -0800 Re: String.replace() with regex Stefan Weiss <krewecherl@gmail.com> - 2011-12-17 14:08 +0100 Re: String.replace() with regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-17 14:12 +0100 Re: String.replace() with regex Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2011-12-17 18:31 +0100
csiph-web