Jump to content

Search the Community

Showing results for tags 'regexp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 3 results

  1. /* Merry Christmas everyone! */ I have an array of objects: arr = [ obj1, obj2 ]; Each object has prototypes: obj1.txt = "az"; obj2.txt = "abc"; obj1.isRoot = false; obj2.isRoot = false; And there's an array called dictionary, it formed like this: var dictionary = [ ["a","(n)"], ["ab","(n)"], ["abc","(n)"], ["abcd","(n)"] ] What I try to achieve is when obj.txt is similar to dictionary[x][0], then obj.isRoot turn to TRUE. I've made the function below so far but it doesn't work. function go(){ for ( i=0; i<arr.length; i++ ){ txt_source = arr[i].txt.replace( /\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\_|\-|\+|\=|\{|\}|\[|\]|\:|\;|\"|\'|<|\>|\,|\.|\?|\/|\\|(0-9)/g, "" ); ori = txt_source.toLowerCase(); regex = new RegExp( '\\b' + ori, 'gi'); for ( m=0; m<dictionary.length; m++ ){ if ( dictionary[m][0].match(regex) ){ arr[i].isRoot = true; // I want this happen for obj2.txt = "abc". } else { arr[i].isRoot = false; } } } console.log( ahoc_arr[x].isRoot ); // all objects always FALSE } Please help! Thanks!
  2. Hello, I'm trying to hide/show table rows using RegExp. And I don't know why I have to create RegExp for each row. This is my script: <!DOCTYPE html><html><body> <table border="1"><tr><td name="c1">row1 col1</td><td name="c2">row1 col2</td></tr><tr><td name="c1">row2 col1</td><td name="c2">row2 col2</td></tr><tr><td name="c1">row3 col1</td><td name="c2">row3 col2</td></tr><tr><td name="c1">row4 col1</td><td name="c2">row4 col2</td></tr><tr><td name="c1">row5 col1</td><td name="c2">row5 col2</td></tr></table> <button onclick="myFunction()">Try it</button> <script>function myFunction(){var c = document.getElementsByName('c1');var re = new RegExp('row', 'ig');var display = 'none';var parent;for(var i = 0; i < c.length; i++){ parent = c[i].parentNode; var display = 'none'; // re = new RegExp('row', 'ig'); if(re.test(c[i].innerHTML)) { display = 'table-row'; }; parent.style.display = display;};}</script> </body></html> And when I click button the even rows disappear but should not.It works fine when I uncomment re = new RegExp('row', 'ig'); in loop.Why I have to create regexp for each step in loop? --Best regardsJacek Q.
  3. I want to extract Have tried:str.match(/[\W]*Lib4[\W]*/); but return nothing. How can I take it out with JavaScript Regular Expression?
×
×
  • Create New...