Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-15-2013, 07:49 PM   PM User | #1
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Unhappy RegEx + string literal + RegEx ?

Hello, everyone.

Is it possible to use a RegEx plus a string plus RegEx to .split() on a string?

Basically put, I'm trying to code a function that will remove a specific user+userID (and other info) from an element .html() value. There is a <div></div> before the name (CSS gives it a "delete" icon) and a <br> after the name (except for the last name in the list - which is causing me the problem.)

Is it possible to take an argument in a function (like the UUID) and pass it as a literal in the middle of a RegEx mask for the .split()?

The .html() value will be something like:
Code:
<div onclick="removeUser'(\'A1234\',\'John Doe\');" class="deleteIcon"></div>John Doe<br>
<div onclick="removeUser'(\'B2345\',\'Zaphod Beeblebrox\');" class="deleteIcon"></div>Zaphod Beeblebrox<br>
<div onclick="removeUser'(\'B3456\',\'Dr. Who\');" class="deleteIcon"></div>Dr. Who<br>
<div onclick="removeUser'(\'C4567\',\'Smithwicks\');" class="deleteIcon"></div>Smithwicks
I figure that if I can split on the <div {data}></div>{user name}(possible<br>) and then join on "", that would make it a simple process.

Right now, I'm splitting on just the name, then trying to clean up all <div></div>(possible <br>) (no name) and it's breaking.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

Last edited by WolfShade; 02-15-2013 at 08:01 PM..
WolfShade is offline   Reply With Quote
Old 02-15-2013, 07:55 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Short answer: of course.

Longer answer: Your explanation was as clear as my cold coffee. Trying to figure out WHAT it is you want to delete from all that.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 02-15-2013, 07:57 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
That HTML you show isn't legal. You have <div>'s but not one single matching </div>.

And what is .html()? Are you talking jQuery? Do you really mean .innerHTML?

And what, if anything, is the container around all of this?

Can't you show the real HTML?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 02-15-2013, 08:00 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Sorry.. as usual, typing fast, missed something. Edited original post to reflect accurate code.

Objective: Delete ONE "<div {attributes}></div>{user name}(possible <br>)" from the list based upon a name passed to the function.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 02-15-2013, 08:47 PM   PM User | #5
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Nevermind. I just made it easier by giving the same UUID to a div that is wrapped around each "<div {attr}></div>name", eliminated all <br> (which made the sort function break, but I fixed it), and am just using jQuery .remove() on those IDs.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:42 AM.


Advertisement
Log in to turn off these ads.