hankknight
asked on
Finding instances of ##foobar##
Using JavaScript, I want var foobar to be the values in the body between ## and ##
For example:
How much ##wood## does a woodchuck ##chuck## if a ##woodchuck## could chuck wood?
I want:
foobar[0] = 'wood';
foobar[1] = 'chuck';
foobar[2] = 'woodchuck';
For example:
How much ##wood## does a woodchuck ##chuck## if a ##woodchuck## could chuck wood?
I want:
foobar[0] = 'wood';
foobar[1] = 'chuck';
foobar[2] = 'woodchuck';
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Something like this perhaps?
<script type='text/javascript'>
var text = 'How much ##wood## does a woodchuck ##chuck## if a ##woodchuck## could chuck wood?'
var info = text.split( '##' )
var result = []
for ( var i = 1; i < info.length; i += 2 ) {
result[ result.length++ ] = info[ i ]
doucment.write( info [i] + '<br>' )
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the grade & points
ASKER
Now your idea returns this:
How much does a woodchuck if a could chuck wood?
So I need JavaScript to find the values of foobar[1] from the body innerHTML