Replace characters and count

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Replace characters and count

danieldotnet
Hello Together
In a long text I should replace two characters (comma and spaces) with
nothing and then count the number of characters left after the replacement.
How can I do this in Orbeon Forms?

Thank you for ideas.
Best regards,
Daniel

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585238555663-0.post%40n4.nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

Alessandro  Vernet
Administrator
Hi Daniel,

Assuming you're using this expression for validation, or something of that
sort that can refer to the current context, the following should do the
trick:

    string-length(translate(., ', ', ''))

You'll let me know if this works for you,

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585257929361-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

danieldotnet
Hi Alessandro
Thank you very much, this works.
I calculate the value (number of characters) divided by 9, I should check
the result for decimal places (result may not have decimal places, must be
INT). Do you have an idea how I can do this check the easiest way?

Best regards and thanks for your help,
Daniel

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585301829909-0.post%40n4.nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

Alessandro  Vernet
Administrator
Hi Daniel,

You can use: `. castable as xs:integer`.
You'll let me know if this is indeed what you were aiming for.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585591733388-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

danieldotnet
Hi Alessandro
Thank you, but in my case this not work without Errors.

if (string-length(translate(., ', ', ''))/9 castable as xs:integer) then
true else false

when I open the form I get the error "An error has occurred while processing
the request."

Best regards,
Daniel

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585816073127-0.post%40n4.nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

Alessandro  Vernet
Administrator
Hi Daniel,

What is the `/9` for in your expression? Is that a typo or where you trying
to do something with the number 9? Also in XPath, it's not `true` and
`false`, but `true()` and `false()`. I.e. those are functions, not keywords,
as is the case in many other languages. Finally, instead of `if (something)
then true() else false()`, you just write `something`.

You'll let me know if with this you manage to do what you were looking for.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1585938144905-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

Alessandro  Vernet
Administrator
Hi Daniel, did you manage to make that expression work? If not, you'll let me
know what you tried and how it fails for you, so we can help.
‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1588008969896-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

danieldotnet
Hi Alex,
Sorry for the late reply. I was able to solve the problem differently, so
this case is over. But thanks for the help.
Best regards,
Daniel

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1588235312032-0.post%40n4.nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Replace characters and count

Alessandro  Vernet
Administrator
Got it Daniel, perfect then, as long as you found a way to filter unwanted
characters, and thank you for the update.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1588350709354-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet