News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Strip$

Started by jj2007, December 16, 2023, 12:18:07 PM

Previous topic - Next topic

jj2007

I always get mad when I put my phone number as 123-456 789 and the website tells me it's not a valid phone number. Or the credit card number as 1111 2222 3333 4444. Some limit the edit field to 16 chars, so that with the spaces, you can't paste the number. That is exceptionally dumb imho :cool:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  PrintLine Strip$("7@89-#456h x123", "1234567890")    ; prints 789456123
  PrintLine Strip$("7@89-#456h x123", exc "@-# xh")    ; 789456123 (exclude chars)
EndOfCode

Strip$ takes a source string plus a string of allowed characters. If the latter is preceded by exc "...", it's a string of disallowed, i.e. excluded characters.

Easy, isn't it? And yet, there are so many "professional" sites that can't do that.

Get MasmBasic version 16 December 2023 to build the above snippet.

P.S.: Don't confuse with Clean$()

NoCforMe

I totally agree on this.

I find it mind-bogglingly unbelievable that here it is, 2023, supposedly deep into the "AI" age, and most websites can't frigging figure out that phone #s, credit card #s, etc., have certain formats, and gracefully allow user input in these fields. Or allow leading or trailing spaces in text fields and gracefully snip them for the user. But no, they want to FORCE the user into their brain-damaged idea of how they should enter information!

Another irritating thing is sites that insist on only allowing Google-approved addresses after you type yours in, and god help you if you try to change "Apt. 7" to "#7" or some other minor formatting change and they reject the whole field as invalid.

The smart ones which I immediately notice are where you're entering a credit card # and the page is smart enough to jump over to the next 4 digits after you enter 4.
Assembly language programming should be fun. That's why I do it.