Reply
Old 04-12-2009, 02:59 PM Regex
evans123's Avatar
Ultra Talker

Posts: 356
Trades: 0
Is it possible to have a regex function find all text within two square brackets

['PLAYER', '29', '280.4', '90.5', 'Benito Basso']

so it just gets 'PLAYER', '29', '280.4', '90.5', 'Benito Basso'
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 04-13-2009, 04:20 AM Re: Regex
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 1,595
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
What's your goal? A RegEx for this seems a bit much -- you could just trim off the first and last character too or, if you want to have an array, you could explode by ',' and trim [, ', and ] characters from the first and last entry in the array.
__________________
Jeremy Miller - TeraTask
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-13-2009, 04:46 AM Re: Regex
Average Talker

Posts: 17
Name: Dmitry
Trades: 0
it should be the following:

Code:
\[(.+)\]
dimok is offline
Reply With Quote
View Public Profile
 
Old 04-13-2009, 05:06 AM Re: Regex
evans123's Avatar
Ultra Talker

Posts: 356
Trades: 0
theres going to be loads of [player,x,x,x,x,] etc.
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
Old 04-13-2009, 05:21 AM Re: Regex
evans123's Avatar
Ultra Talker

Posts: 356
Trades: 0
When i use that regex it just returns "."
Code:
var regexstring = new RegExp("\[(.+)\]");
var myregexp =regexstring.exec(data);
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
Old 04-13-2009, 05:52 AM Re: Regex
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 1,595
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Size doesn't seem to matter:

HTML Code:
<html>
<head>
<script>
var square_bracket_text = "[";
var prefix_string = "";
for (var i=0;i<1000;i++) {
  square_bracket_text += prefix_string + "'" + (Math.floor(Math.random(0,1)*100)) + "'";
  prefix_string = ",";
}
square_bracket_text += "]";

function demo() {
  document.getElementById('original').innerHTML = square_bracket_text;
  document.getElementById('results').innerHTML = square_bracket_text.substring(1,square_bracket_text.length-1);
}
</script>
</head>
<body onLoad="demo();">
<div id="original"></div>
<div id="results"></div>
</body>
</html>
__________________
Jeremy Miller - TeraTask
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Regex
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10232 seconds with 13 queries