gpt4 book ai didi

xquery 自动换行

转载 作者:行者123 更新时间:2023-12-04 17:13:18 25 4
gpt4 key购买 nike

我需要使用 XQuery 将长字符串自动换行到 100 个字符。换句话说,将一些空格更改为换行符,使非病理行短于 100 个字符。有没有简单的方法?

最佳答案

我认为您只需要这个 XPath 2.0 表达式:

replace(concat(normalize-space(text),' '),'(.{0,60}) ','$1
')

使用 Dimitre 的输入,输出:
Dec. 13 — As always for a presidential inaugural, security
and surveillance were extremely tight in Washington, DC,
last January. But as George W. Bush prepared to take the
oath of office, security planners installed an extra layer
of protection: a prototype software system to detect a
biological attack. The U.S. Department of Defense, together
with regional health and emergency-planning agencies,
distributed a special patient-query sheet to military
clinics, civilian hospitals and even aid stations along the
parade route and at the inaugural balls. Software quickly
analyzed complaints of seven key symptoms — from rashes to
sore throats — for patterns that might indicate the early
stages of a bio-attack. There was a brief scare: the system
noticed a surge in flulike symptoms at military clinics.
Thankfully, tests confirmed it was just that — the flu.

关于xquery 自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3767452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com