Skip to main content
Loic.Aigon
Legend
January 23, 2009
Question

[JS CS3] Grep difficulty

  • January 23, 2009
  • 2 replies
  • 249 views
Hi,
I succeeded creating a grep pattern which is used for a string replacement.
var myRegExp = new RegExp ("\..-.*.indd")

if the string is like this, it runs very well :
var x = "001296.01.A-ATELIER GLOTIN.indd";

but like this, it's not satisfying :
var x = "001296.01.ABC-ATELIER GLOTIN.indd";

I cant't get a grep search for a dot, any character n times, a dash, any character n times, a dot, and indd string.
if I do this, var myRegExp = new RegExp ("\..*-.*.indd"), it removes almost everything in the string

What I do wrong ? I am seraching on all grep sites but can't find any clue.
Thanks for light, Loic
This topic has been closed for replies.

2 replies

Loic.Aigon
Legend
January 23, 2009
Hi Peter,
Thanks for help,
It runs as you may expect it ;-)
For a developpement profane such as me, Grep appears as powerful than mysterious.
Peter Kahrel
Community Expert
Community Expert
January 23, 2009
Loic,

Try this: x.match (/\.[^.]+-.+\.indd/)

Peter