aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Regualar expressions in Javascript. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Regualar expressions in Javascript." Watch "Regualar expressions in Javascript." New topic
Author

Regualar expressions in Javascript.

Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
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

Joined: Jan 10, 2002
Posts: 61232
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Ya keep forgetting. That should be on by default.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

Originally posted by Michael Hubele:
That should be on by default.
Not sure what you mean by "that".
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
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

Joined: Jan 10, 2002
Posts: 61232
    
  66

Ah, yeah I agree. It's disabled by default for some forums, but not this one.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Regualar expressions in Javascript.