Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llStripCharacters

Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
03-03-2005 01:32
With the introduction of Unicode font support in 1.6, it occurs to me that at least a few of my scripts simply can't have complete input filtering any longer. There's no way I can make a string machine-readable and meet all eventualities of punctuation anymore.

With that in mind, I suggest llStripCharacters:
string llStripCharacters(string src, integer charset) where 'charset' is ASCII, alphanumeric, alphabetical, uppercase, lowercase, numerical, unicode, and so on. This would allow the removal of all characters not meeting the criteria and would allow for far better data checking.

For example, if I currently were to try to look for the words "hello how are you" in a larger string, case isn't an issue, but there could be any number of punctuation marks, depending on the source's familiarity with the English language. Yes, this is sadly the best example I can think of at the moment, but if it's come up more than once with me, surely such a function would appeal to someone else as well.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Oz Spade
ReadsNoPostLongerThanHand
Join date: 23 Sep 2003
Posts: 2,708
03-03-2005 07:37
I can see this being a problem. I endorse this feature.
_____________________
"Don't anticipate outcome," the man said. "Await the unfolding of events. Remain in the moment." - Konrad
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
03-03-2005 07:56
with a title like llStripCharacter, i thought of something else lol
_____________________
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
03-03-2005 19:53
I hope we get something like llUnicodeValue(string) that gets the integer value of the string's characters (the total, if there is more then one character passed to it). Unicode escape strings (\uXXXX) would be nice too.
Carnildo Greenacre
Flight Engineer
Join date: 15 Nov 2003
Posts: 1,044
03-03-2005 22:50
Heck, just put in support for the full set of Perl regular-expression operations.
_____________________
perl -le '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_++;'
Brian Mifflin
Scripting Addict
Join date: 15 Dec 2004
Posts: 182
03-03-2005 22:55
From: Carnildo Greenacre
Heck, just put in support for the full set of Perl regular-expression operations.


:)
Fearless Leader
Sycophant
Join date: 21 Dec 2004
Posts: 19
03-03-2005 23:26
I agree with Carnildo. Hook up a regular expression library like PCRE...

CODE
llRegexMatch(string str, string regex, integer modifiers);
string llRegexReplace(string str, string regex, string replacement, integer modifiers);


...where modifiers is a bitmask for things like REGEX_CASE_INSENSITIVE.

CODE
# matching in Perl
$str = 'foobarbaz';
$foo = 'bar';

if ($str =~ /\w{3}$foo\w{3}/)
{
# do something
}

// matching in LSL
string str = "foobarbaz";
string foo = "bar";

if (llRegexMatch(str, "\w{3}" + foo + "\w{3}", 0))
{
// do something
}

# replacement in perl
$str = 'The Philadelphia Experiment';
$str =~ s/^(an?|the)\s*(.*)$/$2, $1/i;

// replacement in LSL
string str = "The Philadelphia Experiment";
str = llRegexReplace(str, "^(an?|the)\s*(.*)$", "$2, $1", REGEX_CASE_INSENSITIVE);


Thoughts? I think an approach like this would give us a lot of power. Using methods instead of providing first-class support for regexes in LSL also make the change much less drastic.
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
03-04-2005 00:08
Yes, regex is really what I want, but I've always come away with the feeling that it's a little much to hope for. :)
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Jack Lambert
Registered User
Join date: 4 Jun 2004
Posts: 265
03-04-2005 01:45
Oh wow regex in SL would be so SEXY!!

Please do it Lindens! PLEASE, for the love of Perl!

--Jack Lambert
Walker Spaight
Raving Correspondent
Join date: 2 Jan 2005
Posts: 281
03-04-2005 14:56
and here I was thinking llStripCharacters was going to let us see underneath an avatar's clothes.

I guess that would be llStripAvatar