Jump to content

Krupa

Members
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Krupa

  • Rank
    Newbie
  • Birthday 11/18/1991

Previous Fields

  • Languages
    JavaScript

Contact Methods

  • AIM
    None
  • MSN
    None
  • ICQ
    0
  • Yahoo
    None

Profile Information

  • Location
    Canada
  1. Krupa

    RegExp Help

    Now b is null. This script is oddly more complex than I thought it was going to be (function() { if (/blah/.test(location.href)) { var reg_whisper = /\[whisper\=(.+?)\](.+?)\[\/whisper\]/gi; $('selector').each(function() { if (this.innerHTML.match(reg_whisper)) { var a = this.innerHTML.match(reg_whisper); var index = 0; while (index < a.length) { var b = reg_whisper.exec(a[0]), c = b[1], d = c.split(","), e = d.length, x = $('#top_info strong').text(), y='', z=''; while (e--) { y = d[e]; if (d[e].toLowerCase() === x.toLowerCase()) { z = this.in
  2. Krupa

    RegExp Help

    <script type='text/javascript'>/* <![CDATA[ */(function() { if (/blahblah/.test(location.href)) { var reg_whisper = /\[whisper\=(.+?)\](.+?)\[\/whisper\]/gi; $('selector').each(function() { var a = this.innerHTML.match(reg_whisper); var index = 0; while (index < a.length) { if (this.innerHTML.match(reg_whisper)) { var b = reg_whisper.exec(a[0]), c = b[1], d = c.split(","), e = d.length, x = $('#top_info strong').text(), y='', z=''; while (e--) { y = d[e]; if (d[e].toLowerCase() === x.toLowerCase()) { z = this.innerHTML.replace(a[index], "
  3. Krupa

    RegExp Help

    Now I'm getting the error a is null and underneath that message is </div>
  4. Krupa

    RegExp Help

    Firebug is throwing index is not defined
  5. Krupa

    RegExp Help

    That ended up copying/pasting the match on each instance of the pattern - I had 5 in my test area and it posted 25 of everything in the test area.
  6. Krupa

    RegExp Help

    I tried it without the function and all of the instances of the match change to the same thing. With the function however, the instances all change to what they should. For example - without the function I would have something like this: [whisper=Matt,Dave,Jon]Hello[/whisper][whisper=Time,Dave,Alex]There[/whisper][whisper=Matt,Paul,Zach]Everyone[/whisper]// after the code runs those would all becomeHelloHelloHello With the function, this is what would happen. [whisper=Matt,Dave,Jon]Hello[/whisper][whisper=Time,Dave,Alex]There[/whisper][whisper=Matt,Paul,Zach]Everyone[/whisper]// after the c
  7. Krupa

    RegExp Pattern

    Didn't think it was that simple. I ended up getting it to work the way I wanted it to, thank you everyone!Also, the reason I'm not using ID's to target certain links or CSS to style them is because it is open for edits; there is no specific anchor or style to be set - it's set by the user.
  8. Krupa

    RegExp Pattern

    The only problem is that I need to be able to wrap new HTML tags around whatever is inside the <a> tag.
  9. I'm working on something that I can't quite get the pattern working for. I'm trying to detect <a> tags and then isolate anything and everything between the <a....> and the </a> so that I can manipulate it and then later add the <a.....></a> back to the HTML.For example, let's say we have this <a href='LINK'><strong><u>TEXT</u></strong></a> I am trying to reduce that to what's contained in the <a> tag, manipulate it (mostly adding more HTML) and then wrapping everything back up with the <a> tags.I have been fiddling
  10. Krupa

    RegExp Help

    The reason for that function is to return once the "<span class='whisper'>" +RegExp.$2+ "</span>" has been set. Without the function, all of the matched patterns are replaced with the same value instead of their individual value (if that made any sense). I don't know if this would have had any impact on your solution (this just hit me now) but there are some cases where there will be more than one pattern in each selector. So for example: <div id="one">[x=blah,bleh,meh]Text 1[/x][x=hi,bleh,meh]Text 2[/x][x=John,Joe,Matt]Text 3[/x]</div>// One selector<div id="two"&g
  11. Krupa

    RegExp Help

    Odd. Your example works, but mine still will not. if (this.innerHTML.match(reg_whisper)) { var a = this.innerHTML.match(reg_whisper), b = reg_whisper.exec(a[0]), c = b[1], d = c.split(","), e = d.length, x = $('#top_info strong').text(), y = '', z = ''; while (e--) { y = d[e]; if (d[e].toLowerCase() === x.toLowerCase()) { z = this.innerHTML.replace(reg_whisper, function() { return "<span class='whisper'>" +RegExp.$2+ "</span>"; }); break; } else { z = this.innerHTML.replace(reg_whisper, '[HIDDEN MESSAGE]'); } } this.innerHTML = z
  12. Krupa

    RegExp Help

    Still having a little bit of a problem. Now the first part of the if statement returns true every time; even when b[c] is not equal to x the matched pattern is replaced with the RegExp.$2. var a = this.innerHTML.match(reg_x), b = reg_x.exec(a)[1].split(","), c = b.length, x = $('#top_info strong').text(), y; while (c--) { if (b[c].toLowerCase() === x.toLowerCase()) { y = this.innerHTML.replace(reg_x, function() { return "<span class='somespan'>" +RegExp.$2+ "</span>"; }); break; } else { y = this.innerHTML.replace(reg_x, '[HIDDEN MESSAGE]'); } } this.innerHTML
  13. Krupa

    RegExp Help

    Oh! That makes sense I understand the problem but I'm not exactly clear on how to implement your solution. How would my if statement look with that new variable being used?
  14. Krupa

    RegExp Help

    Everything seems to run perfectly. It's just that for some reason unless the value of x is equal to the first value of b[c] the code doesn't work as it should. Even if another index of b[c] is equal to x, it won't work unless it's the first value to be matched. It's supposed to work if any of the parameters match x.Here's the code so you don't need to go back a page var reg_w = /\[x\=(.+?)\](.+?)\[\/x\]/gi; if (this.innerHTML.match(reg_w)) { var a = this.innerHTML.match(reg_w), b = reg_w.exec(a)[1].split(","), c = b.length, x = $('selector').text(); while (c--) { b[c].toLowerCase
  15. Krupa

    RegExp Help

    It still seems to be doing the same thing. I'm really stumped as to what the problem could be.
×
×
  • Create New...