Forum Moderators: open

Message Too Old, No Replies

how to tweak a regex syntax?

need a little bit help on how to modify a regex expression

         

sugar2

9:30 am on Dec 8, 2008 (gmt 0)

10+ Year Member



Hello to all.. =)
I just installed an ajax suggestion tool in my website

It works great, but it doesn't work cross-domain, the way it is designed is as follows, in a input tag, you write "url-search-uni.php", then the javascript code, removes the "url-" and just call the remaining "search-uni.php",

<input type="text" class="ajax-suggestion url-search-uni.php">

I asked the developer how to tweak the javascript to have it able to process a input like:

<input type="text" class="ajax-suggestion url-http://mysite.com/js/search-uni.php">

He told me that it should work if a line in the file: ajaxSuggestions.js

told me that tweaking this line it can allow the form to accept and process a url input instead of only the filename,

var url = this.currentElm.className.replace(/.*url-([\w\/\?\.-]+).*/, "$1");

and that will result in a cross-domain script, the thing is that I found refex too complicated for me =(
Can please somebody giveme a start point?

Thanks in advance!

[edited by: coopster at 7:11 pm (utc) on Dec. 8, 2008]
[edit reason] removed link [/edit]

coopster

7:28 pm on Dec 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The regular expression pattern specified matches zero or more of anything
.*
followed by
url-
and then the matching subpattern. Matching subpatterns have parentheses surrounding them. I would like to believe that you could merely change that pattern to find anything after that which does not match either a space character or another double quotation mark.
var url = this.currentElm.className.replace(/.*url-([^\s"]+).*/, "$1");

You will have to test to be certain.

sugar2

9:02 pm on Dec 8, 2008 (gmt 0)

10+ Year Member



Thanks, it seems to do the job of load an external file... but now I am getting the "ns_error_dom_bad_URI" error, which means that I cannot make a httprequest calling a external file =(