0

I have requirement .. We have to allow Only characters and Number only in xslt. if any special character will come we have to replace with blank.. we can use Translate function but we don't know which character will come it may come some latin character also..

If My input Is #$ABcd@1234 --- My result will like this ABcd1234

am using XSLT 1.0 and Can we use Replace Function In XsLT 2.0

Pls help me on this

Thanks, Ravi

yadav b
  • 21
  • 4
  • 1
    You've tagged this both as xslt-1.0 and xslt 2.0, but the tags are meant to be mutually exclusive. If you can use xslt 2.0, then you should! In xslt 2.0 you could also use the `replace` function, for example. It would help if you showed some examples of your inputs and your expected output too. Thanks! – Tim C Oct 04 '14 at 09:05
  • Please explain what exactly is (or isn't) a *character* in this context. – michael.hor257k Oct 04 '14 at 09:14
  • Possible duplicate of http://stackoverflow.com/questions/5084065/replace-special-characters-in-xslt You'll find answers there for both xslt 1.0 and xslt 2.0 – matthias_h Oct 04 '14 at 09:55
  • My question still stands. An example is not a **rule**. For example, what would be the expected output of "Beyoncé" or "ß-rays" or ... ? – michael.hor257k Oct 04 '14 at 10:05
  • hi Michael thanx for u r reply... For "Beyoncé" ---> My expected and is Beyonc and ß-rays My expected ans is rays....and i guess Matthias_H is given Correct Suggestion... http://stackoverflow.com/questions/5084065/replace-special-characters-in-xslt – yadav b Oct 04 '14 at 10:50
  • Good. Then why don't you delete this question. – michael.hor257k Oct 04 '14 at 13:06

1 Answers1

0

If by "character" you mean "letter", and if you accept the Unicode definition of a "letter" (which includes letters in non-Latin alphabets), then you can do

replace($input, '[\P{L}\P{Nd}]', '')
Michael Kay
  • 156,231
  • 11
  • 92
  • 164