Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regualar expressions in Javascript.

 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to do a regular expression that just grabs the filename(not the extension of an image file). I have ton's of files and they all are in different folders so it needs to be generic enough so one fits all case.

So far I use a program called Expresso that allows your to write the regular expression and see it filter. Then we your done you can generate C# code for it. It does not support javascript though.

So I got this:

(?imx-sn [a-z]*/(?<character>[a-z]+)\.\bgif\b

(?imx-sn - stuff for ignoring case and lines.

?<character>[a-z]+)- I want to capture this in a name class and call this later.

So I don't really know how to make this into javascript syntax. I am also unsure if this will effect Jquery(or if it need anything special) since this will be embedded in a jquery method(the .each loop)

Sample img links:

<img style="border-width: 0px;" src="Images/Hiragana/a-o/a.gif"/>
<img style="border-width: 0px;" src="Images/Hiragana/Special-Characters/Ten-Ten/ga-go/ga.gif"/>
[ June 14, 2008: Message edited by: Michael Hubele ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Hubele:
(?imx-sn [a-z]*/(?<character>[a-z]+)\.\bgif\b
You'll need to be sure that 'disable smilies' is checked when posting code. That way, you're regular expressions will look less happy.
I am also unsure if this will effect Jquery(or if it need anything special) since this will be embedded in a jquery method(the .each loop)
jQuery is just JavaScript. No effect.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya keep forgetting. That should be on by default.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Hubele:
That should be on by default.
Not sure what you mean by "that".
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Not sure what you mean by "that".


Sorry. I meant the "Disable smilies in this post" should be on by default.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, yeah I agree. It's disabled by default for some forums, but not this one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic