Special Characters at the end of a string

View: New views
3 Messages — Rating Filter:   Alert me  

Special Characters at the end of a string

by Dave Hannum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I want to look at the last character in a string, and see if it is something other than a letter of the alphabet, a number or a question mark (?).  In other words, I don't what the last character of a string to be a special character (other than "?").  Would someone be kind enough to show me how this is done.  - thanks

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:881
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: Special Characters at the end of a string

by Ben Doom :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To test, you could use:

if (refindnocase("[^a-z0-9?]$", string)) { do whatever }

To remove any "special" chars, you could modify it slightly into:

string = rereplacenocase(string, "[^a-z0-9?]+$", "");

Not tested, may need tweaking, YMMV, keep head and arms inside the car
at all times, etc.  If you want an explanation or more help.  Feel free
to ask.

This has been a service of the HouseOfFusion Regex Ninja Squad.

--Ben

David Hannum wrote:
> I want to look at the last character in a string, and see if it is something other than a letter of the alphabet, a number or a question mark (?).  In other words, I don't what the last character of a string to be a special character (other than "?").  Would someone be kind enough to show me how this is done.  - thanks
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get Instant Hacker Protection, Virus Detection, Antispam & Personal Firewall.
http://www.houseoffusion.com/banners/view.cfm?bannerid=62

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:882
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: Special Characters at the end of a string

by Dave Hannum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Ben - I think that just about does it.  Dave 8-)


> To test, you could use:
>
> if (refindnocase("[^a-z0-9?]$", string)) { do whatever }
>
> To remove any "special" chars, you could modify it slightly into:
>
> string = rereplacenocase(string, "[^a-z0-9?]+$", "");
>
> Not tested, may need tweaking, YMMV, keep head and arms inside the
> car
> at all times, etc.  If you want an explanation or more help.  Feel
> free
> to ask.
>
> This has been a service of the HouseOfFusion Regex Ninja Squad.
>
> --Ben
>
> David Hannum wrote:
> > I want to look at the last character in a string, and see if it is
> something other than a letter of the alphabet, a number or a question
> mark (?).  In other words, I don't what the last character of a string
> to be a special character (other than "?").  Would someone be kind
> enough to show me how this is done.  - thanks
> >
> >

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:21:883
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54