| Blockland Forums > Modification Help |
| Removing all tags |
| << < (2/4) > >> |
| Brian Smithers:
--- Quote from: Lugnut1206 on March 02, 2012, 06:30:59 PM --- 1 Aren't there wildcards in torque? 2 is it absolutely neccesary to do this ingame? --- End quote --- 1 whats that 2 if it wasn't then I wouldn't have posted. |
| phflack:
i think i got it --- Code: ---function findNextTag(%string) { %start = strPos(%string,"<"); %end = strPos(%string,">"); return %start SPC %end; } function removeTags(%string) { while(findNextTag(%string) !$= "-1 -1") { %tagpos = findNextTag(%string); %start = getWord(%tagpos,0); %end = getWord(%tagpos,1); %sut = getSubStr(%string,0,%start); %eut = getSubStr(%string,%end,strLen(%string) - 1); %newstr = %sut @ %eut; } return %newstr; } --- End code --- i was testing the first function echo(findNextTag("hi<bluh>quack")); returned 2 7 echo(findNextTag("blub")); returned -1 -1 and i think the substring has to be a valid position in the string, maybe not |
| Brian Smithers:
--- Quote from: phflack on March 02, 2012, 06:44:04 PM ---and i think the substring has to be a valid position in the string, maybe not --- End quote --- getSubStr(string,start,end) - Used to get a section of a string. Start and End are integers. EDIT: Crashed me. |
| phflack:
um, just tested it i think i crashed... not sure though haha and i know they're integers, but does it have to be a valid position in the string? ie duckquack 012345678 would subString("duckquack", 0, 10); return duckquack or an error? edit: closed it due to being frozen... and fuuu, now i gotta retype it all edit: oh, duh we're not updating the stuff in the while loop edit again: test this? --- Code: ---function findNextTag(%string) { %start = strPos(%string,"<"); %end = strPos(%string,">"); return %start SPC %end; } function removeTags(%string) { %newstr = %string; while(findNextTag(%newstr) !$= "-1 -1") { %tagpos = findNextTag(%string); %start = getWord(%tagpos,0); %end = getWord(%tagpos,1); %sut = getSubStr(%string,0,%start); %eut = getSubStr(%string,%end,strLen(%string) - 1); %newstr = %sut @ %eut; } return %newstr; } --- End code --- |
| Jardev:
Shouldn't --- Code: --- %newstr = %string; --- End code --- Go inside the while() statement? |
| Navigation |
| Message Index |
| Next page |
| Previous page |