How to check whether given input text contains special characters or not using XSL tags [closed] - xslt-3.0

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
How to check whether given input string contains special characters or not
Input : A'ACHARYA NG'ANGA MAURY'A
Contains special characters
OUTPUT : A'acharya Ng'anga Maury'a

You've tagged your question as xslt-2.0, so I'll mention the regex function matches(), which you can use to test whether a string matches a regular expression. See https://www.w3.org/TR/xquery-operators/#func-matches
Input:
<test>Aacharya Ng%anga Maury&a</test>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="text"/>
<!-- define a regex to match "special" characters -->
<xsl:variable name="specials-regex">[%&]</xsl:variable>
<xsl:template match="/test">
<xsl:value-of select="matches(., $specials-regex)"/>
</xsl:template>
</xsl:stylesheet>
Output:
true
The regular expression language would allow you to define "special" in any way you want, either by listing the characters individually (as I did, above) and/or using the "character classes" defined here: https://www.w3.org/TR/xmlschema-2/#charcter-classes, e.g \p{S} meaning "Symbols", or \P{L} meaning "anything except letters".

Related

regex to match the pattern in python3 using match method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to know the regex using re.match method to match below pattern.
some action 1.1.1.1 on sub.domain.com
Currently I'm using below code, which works fine but I want to strip of everything except sub.domain.com because using below code I'm getting something like <http:\\/\\/sub.domain.com|sub.domain.com>
some\s+action+\s+(.*)\s+on\s+(.*)
This is where you would use a capturing group. Notice you have two capturing groups in your question, but you only want one. Here would be an example of one where you get the captured group after the first four "words" (defined as one or more non-spaces plus a space):
(?:\S+\s){4}(.*)
Also note that in actual practice this wouldn't work too well -- what if "some action" is ten words? Instead you might want to do something more targeted such as a regex to match (in pseudocode) <IP> on (<domain>).
>>> import re
>>> s='some action 1.1.1.1 on sub.domain.com'
>>> re.match(r'(?:\S+\s){4}(.*)', s).group(1) # not using anchors, not sure if you need that?
# 'sub.domain.com'

Removing special characters in field name using groovy [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a field <Age (D.O.B)>.I want the result to be i,e Age in brackets (unable to see my tag here)
I am using groovy.Please help.
I tried escaping the characters but unable to.
def msgBodyModified21 = msgBodyOriginal.replaceAll('<Age'+\\s+'(D.O.B)>', '<Age>')
Your quoting on the regexp is wrong. Use:
"<Age (D.O.B)>".replaceAll(/<Age\s+\(D\.O\.B\)>/, "<Age>")

How to replace occurances of a string with changing values in kotlin? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have the current string "number number number number number" and I would like to replace it with "1 2 3 4 5". How do i replace occurrences of a string with incrementing numbers in Kotlin?
Your idea of a solution in the comment is in the right direction.
The way to do this using a single call to the standard library is this:
var i = 1
val result = text.replace("number".toRegex()) { _ -> "${i++}" }
(runnable sample)
This replace overload accepts a function that is called on each MatchResult (which is ignored in this case)

How to return raw XML from a fetch request? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have to retrieve XML data from a server. I'm using Fetch since I need an async/await compatible way of making HTTP requests.
However using resp.text() when retrieving the data via fetch causes it to escape all quotes and newlines.
Here's what the result should look like:
<?xml version="1.0" encoding="UTF-8"?><data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<value var_id="v04" xsi:type="ELEMENT">hello</value>
</data>
And here's what it actually looks like:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><data xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <value var_id=\"v04\" xsi:type=\"ELEMENT\">hello</value>\n</data>\n"
Anyway I can prevent this and receive the raw XML? Alternatively, anyway to parse it back to its original form? Thanks.
Doing .text in node-fetch just does:
return consumeBody.call(this).then(buffer => buffer.toString());
This is literally the source code of .text
Which is just a Node Buffer#toString() - that does no escaping one way or another.
Node.js does escape strings before printing them so you can use them and copy-paste them.
Rest assured - this is just a UI visibility feature - not an actual text escaping change :)

How to check if a given String is an English word in Scala? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am looking for some library which take string as input and result boolean based on, if input string is present in english dictionary
For mac user default english dictionary can be found at location /usr/share/dict/web2
Hence we can,
>> var dict = scala.io.Source.fromFile("/usr/share/dict/web2").getLines.toSet
>> dict.contains("apple")
result : true
>> dict.contains("appl")
result : false

Resources