Re: [Proto-Scripty] Re: how to modify a part of an a href=...
I found one called Reggy quite a while ago. It's written by Sam Souder, but I don't have a URL for it. Walter On Aug 20, 2010, at 2:26 AM, Erwin wrote: thanks I'll look at that... and maybe try to find a RegExp app for Mac... On 19 août, 21:01, Dave Kibble davekib...@gmail.com wrote: depends entirely on what you are trying to capture - is the edit always there? is the /admin/users/ always there? yes... they are, only the 'id' number is going to change in general I'm a great fan ofhttp://www.w3schools.com/but not sure what to recommend for regular expressions in general - most sites are confusing rather than educational for the novice :) you can tryhttp://www.w3schools.com/jsref/jsref_obj_regexp.asp On 19 August 2010 14:26, Erwin yves_duf...@mac.com wrote: I tried the following var editRegExp = /(^.*?)([^\/]*)\/edit\?(.*$)/; var edit_link = $('edit_user').down('a'); var match = editRegExp.exec(edit_link.href.toString()); on this url : /admin/users/4c6a275ea326cb01f401/edit?locale=en seems to work , maybe a better writing ? On 19 août, 15:10, Erwin yves_duf...@mac.com wrote: Hi Dave .. sorry to ask you an additional trick ... but as you are qui good in RegExp ... what if the href is as following : /admin/users/4c6a275ea326cb01f401/edit?locale=en in this case (^.*?) is getting the 'edit' string, not the id number : 4c6a275ea326cb01f401 btw : which tutorial do you recommend to get a better understanding of RegExp ..? (I found some of them w good explanation but few examples;..) erwin On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en . -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en . -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
Hi Dave .. sorry to ask you an additional trick ... but as you are qui good in RegExp ... what if the href is as following : /admin/users/4c6a275ea326cb01f401/edit?locale=en in this case (^.*?) is getting the 'edit' string, not the id number : 4c6a275ea326cb01f401 btw : which tutorial do you recommend to get a better understanding of RegExp ..? (I found some of them w good explanation but few examples;..) erwin On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
I tried the following var editRegExp = /(^.*?)([^\/]*)\/edit\?(.*$)/; var edit_link = $('edit_user').down('a'); var match = editRegExp.exec(edit_link.href.toString()); on this url : /admin/users/4c6a275ea326cb01f401/edit?locale=en seems to work , maybe a better writing ? On 19 août, 15:10, Erwin yves_duf...@mac.com wrote: Hi Dave .. sorry to ask you an additional trick ... but as you are qui good in RegExp ... what if the href is as following : /admin/users/4c6a275ea326cb01f401/edit?locale=en in this case (^.*?) is getting the 'edit' string, not the id number : 4c6a275ea326cb01f401 btw : which tutorial do you recommend to get a better understanding of RegExp ..? (I found some of them w good explanation but few examples;..) erwin On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: how to modify a part of an a href=...
depends entirely on what you are trying to capture - is the edit always there? is the /admin/users/ always there? in general I'm a great fan of http://www.w3schools.com/ but not sure what to recommend for regular expressions in general - most sites are confusing rather than educational for the novice :) you can try http://www.w3schools.com/jsref/jsref_obj_regexp.asp On 19 August 2010 14:26, Erwin yves_duf...@mac.com wrote: I tried the following var editRegExp = /(^.*?)([^\/]*)\/edit\?(.*$)/; var edit_link = $('edit_user').down('a'); var match = editRegExp.exec(edit_link.href.toString()); on this url : /admin/users/4c6a275ea326cb01f401/edit?locale=en seems to work , maybe a better writing ? On 19 août, 15:10, Erwin yves_duf...@mac.com wrote: Hi Dave .. sorry to ask you an additional trick ... but as you are qui good in RegExp ... what if the href is as following : /admin/users/4c6a275ea326cb01f401/edit?locale=en in this case (^.*?) is getting the 'edit' string, not the id number : 4c6a275ea326cb01f401 btw : which tutorial do you recommend to get a better understanding of RegExp ..? (I found some of them w good explanation but few examples;..) erwin On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: how to modify a part of an a href=...
I've done well with Regex buddy, but we ended up buying the program. Its interface lets you experiment with regular expressions for various languages, which is far better than examples. On Thu, Aug 19, 2010 at 3:01 PM, Dave Kibble davekib...@gmail.com wrote: depends entirely on what you are trying to capture - is the edit always there? is the /admin/users/ always there? in general I'm a great fan of http://www.w3schools.com/ but not sure what to recommend for regular expressions in general - most sites are confusing rather than educational for the novice :) you can try http://www.w3schools.com/jsref/jsref_obj_regexp.asp On 19 August 2010 14:26, Erwin yves_duf...@mac.com wrote: I tried the following var editRegExp = /(^.*?)([^\/]*)\/edit\?(.*$)/; var edit_link = $('edit_user').down('a'); var match = editRegExp.exec(edit_link.href.toString()); on this url : /admin/users/4c6a275ea326cb01f401/edit?locale=en seems to work , maybe a better writing ? On 19 août, 15:10, Erwin yves_duf...@mac.com wrote: Hi Dave .. sorry to ask you an additional trick ... but as you are qui good in RegExp ... what if the href is as following : /admin/users/4c6a275ea326cb01f401/edit?locale=en in this case (^.*?) is getting the 'edit' string, not the id number : 4c6a275ea326cb01f401 btw : which tutorial do you recommend to get a better understanding of RegExp ..? (I found some of them w good explanation but few examples;..) erwin On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
On 18 Ago, 16:51, Erwin yves_duf...@mac.com wrote: I have the following html code in my page li style=display: none; id=show_user class=basic_link a href=/admin/users/4c6a275ea326cb01f401?locale=enShow User/a /li I would like to modify the id part of the href (4c6a275ea326cb01f401) between the '/admin/users/' string and the '?locale=en' string (always present) with the value of a variable: var id= selection[0].id; I know that in order to get the element to be modified , I can write : $('show_user').firstDescendant() but then .. I don't know how to modify it .. any help will be welcome erwin Hi I´m not an expert so this is a simple workaround. This will only work if 4c6a275ea326cb01f401 is a static value // some prevoius value var id= selection[0].id; //get the string from tue url var mylink=$('show_user').firstDescendant().getAttribute('href'); //replace '4c6a275ea326cb01f401' with id value mylink=mylink.replace( '4c6a275ea326cb01f401', id ); //set the new value to the url $('show_user').firstDescendant().setAttribute('href')=mylink; if 4c6a275ea326cb01f401 is a dynamic value one may as well use a similar process except that the url string has to be splitted into smaller parts and then filled with the proper values . Hope this can help you. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
thanks a lot , will keep it in my PrototypeTricks folder On 18 août, 19:27, Dave Kibble davekib...@gmail.com wrote: you might find this regular expression useful: var myRegExp = /(^.*?)([^\/]*)\?(.*$)/; var match = myRegExp.exec(link.href.toString()); alert(match[1] + '\n' + match[2] + '\n' + match[3]); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
Thanks a lot, unfortunately the is number is not a static value .. this is why I want to modify it when user selects a checkbox in a list On 18 août, 19:00, greeny netpl...@gmail.com wrote: On 18 Ago, 16:51, Erwin yves_duf...@mac.com wrote: I have the following html code in my page li style=display: none; id=show_user class=basic_link a href=/admin/users/4c6a275ea326cb01f401?locale=enShow User/a /li I would like to modify the id part of the href (4c6a275ea326cb01f401) between the '/admin/users/' string and the '?locale=en' string (always present) with the value of a variable: var id= selection[0].id; I know that in order to get the element to be modified , I can write : $('show_user').firstDescendant() but then .. I don't know how to modify it .. any help will be welcome erwin Hi I´m not an expert so this is a simple workaround. This will only work if 4c6a275ea326cb01f401 is a static value // some prevoius value var id= selection[0].id; //get the string from tue url var mylink=$('show_user').firstDescendant().getAttribute('href'); //replace '4c6a275ea326cb01f401' with id value mylink=mylink.replace( '4c6a275ea326cb01f401', id ); //set the new value to the url $('show_user').firstDescendant().setAttribute('href')=mylink; if 4c6a275ea326cb01f401 is a dynamic value one may as well use a similar process except that the url string has to be splitted into smaller parts and then filled with the proper values . Hope this can help you. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: how to modify a part of an a href=...
Thanks a lot, I am using RoR, but now (Rails 3) requires people to get a better knowledge of js... I'll need to work on it On 18 août, 18:21, Walter Lee Davis wa...@wdstudio.com wrote: On Aug 18, 2010, at 11:51 AM, Erwin wrote: I have the following html code in my page li style=display: none; id=show_user class=basic_link a href=/admin/users/4c6a275ea326cb01f401?locale=enShow User/a /li I would like to modify the id part of the href (4c6a275ea326cb01f401) between the '/admin/users/' string and the '?locale=en' string (always present) with the value of a variable: var id= selection[0].id; I know that in order to get the element to be modified , I can write : $('show_user').firstDescendant() I would use var link = $('show_user').down('a'); but then .. I don't know how to modify it .. Now that you have the existing link, and the new bit you want to replace, it's just a matter of string splitting and re-assembly. If the /admin/users/ part is always the same, you could do something really simple like this: (wrap this whole thing in a test for link's existence, so you don't get bitten if the HTML changes later) var new = '/admin/users/' + id + '?' + link.href.toString().split('?').last(); and finally, link.href = new; and you're done. Walter any help will be welcome erwin -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en . -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.