首页 \ 问答 \ 正则表达式如何用字符串中的实际换行替换\ r \ n(Regex how to replace \r\n with an actual newline in string)

正则表达式如何用字符串中的实际换行替换\ r \ n(Regex how to replace \r\n with an actual newline in string)

因为\ r \ n是正则表达式中的“特殊”字符,我在确定实际需要放入表达式时遇到问题。

基本上我有一个看起来像......的字符串

bla\r\nbla\r\nbla

..而我正想把它改成......

bla
bla  
bla

...使用正则表达式。

有任何想法吗?


Because \r\n are "special" chars in a regex I have a problem identifying what I actually need to put in my expression.

basically i have a string that looks something like ...

bla\r\nbla\r\nbla

.. and i'm looking to change it to ...

bla
bla  
bla

... using a regular expression.

Any ideas?


原文:https://stackoverflow.com/questions/11539945
更新时间:2024-01-18 21:01

最满意答案

如果您只想返回最新记录,应用程序应使用last_updated时间戳查询您的API。

基于此,您可以过滤查询集以匹配上次用户刷新时间轴时添加的记录。

如果未设置时间戳,则返回所有记录(或按创建日期排序的部分记录)。


If you only want to return the latest records, the app should query your API with a last_updated timestamp.

Based on that you can filter your queryset to match the records that have been added the last time the user has refreshed his timeline.

If no timestamp is set, you return all records (or a part of it ordered by date of creation).

相关问答

更多
  • 如果您只想返回最新记录,应用程序应使用last_updated时间戳查询您的API。 基于此,您可以过滤查询集以匹配上次用户刷新时间轴时添加的记录。 如果未设置时间戳,则返回所有记录(或按创建日期排序的部分记录)。 If you only want to return the latest records, the app should query your API with a last_updated timestamp. Based on that you can filter your querys ...
  • 最后,谷歌发布了一个官方版本的即插即用库! 在支持库中,称为SwipeRefreshLayout,文档在此处: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html Finally, Google released an official version of pull-to-refresh library! It is called SwipeRefreshLayout, insi ...
  • 为什么不将令牌持久存储到数据库中? 然后,如果服务器崩溃,您将不会丢失令牌。 此外,您可以通过在向无效令牌发送消息后检查来自GCM的错误响应来完成刷新无效令牌,如果您获得了例如Unregistered Device,那么您所要做的就是从数据库中删除该令牌。 在这里和这里查看更多细节 Why don't you persist the token into a database ? Then you won't loose the tokens if the server crashes. In additi ...
  • 不是.JWT的重点是包含JWT本身的所有内容,以便能够识别用户。 没有理由在服务器端存储JWT(除非您想以某种方式维护列入黑名单/已撤销的JWT的列表,但即使这样,JWT内部的ID或其他内容也应该足够)。 不是.JWT的重点是包含JWT本身的所有内容,以便能够识别用户。 这正是允许避免会话和完全无状态的原因:您收到JWT,如果您知道用于签名的密钥,您就可以知道用户是谁,并确保JWT没有被伪造。 我想你需要了解JWT是什么,以及它们是如何工作的。 为什么要存储JWT? No. The whole point ...
  • 我不认为getParameter(“refreshCount”)是servlet的自动功能。 看起来它只是在查询字符串(URL)中获取refreshCount参数的值。 最有可能的是,代码的其他部分正在设置该值。 即使Servlet类正在自动跟踪它,也需要维护该客户端的会话状态。 GWT RPC调用没有任何内置的会话功能。 所以如果你想这样做,你有两个选择: 您可以在客户端中维护“刷新计数”变量,并将其作为参数传递给RPC方法。 您可以将某种会话ID传递到每个RPC方法调用中,并跟踪服务器端的刷新计数。 这 ...
  • 有多种方法可以做到这一点(与编程中的所有内容一样!)。 我通常这样做的方法是在数据库中存储一个时间戳,每次用户(或受其影响的任何用户)进行任何类型的交互时都会检查该时间戳。 如果时间戳已过,则应调用该事件。 另一种方法(如果我没记错,这就是laravel的工作方式)是如上所述,但不依赖于用户交互,某种类型的cronjob或预定作业是检查用户的触发器/秒。 因此,每次cronjob触发时(取决于它必须接近的时间,如果需要,该作业可以每秒触发)它将检查每个用户以查看他们的时间戳是否比当前时间戳更旧,并且在这种情 ...
  • 使用Web套接字。 你可以使用这个或那个PHP套接字 我认为php Sockets会要求你拥有5.3或更高版本的PHP版本。 如果您没有PHP v5.3或更高版本,则可以将Node JS与Socket.io一起使用 Long Pooling也是一种选择,但考虑到服务器获得的请求数量,这不是一个好的解决方案。 此外,用户的带宽使用率也会很高。 Use Web Sockets. You can use either PHP Sockets with this or this I think php Socket ...
  • 查看令人敬畏的ActionBar-PullToRefresh库。 它使用gmail / google +进度条进行拉动以刷新手势,高度可配置,非常易于实施。 Check out the awesome ActionBar-PullToRefresh Library. It does the pull to refresh gesture using the gmail/ google+ progress bar, is highly configurable, very easy to implement. ...
  • PJSIP实现了整个SIP协议。 所以是的:它也可以用来实现服务器。 该库附带了许多示例,例如代理服务器。 你可以从那里开始。 PJSIP implements the whole SIP protocol. So yes: it can also be used to implement a server. The library comes with many samples, e.g. a proxy server. You can start from there.
  • OWASP JSON Sanitizer将类似JSON的输入转换为语法上有效且可嵌入的JSON。 它通常用于在服务器上采用由ad-hoc方法生成的“JSON” "{ \"output\": " + stringOfJson + " }" 并确保它在语法上有效,以便它可以传递到客户端上的JSON.parse ,并且可嵌入,以便它可以嵌入到更大的HTML或XML响应中,如 如果您的客户可能发送 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)