如何在索引0处查找新行字符 [英] How to find the new line character at index 0

查看:72
本文介绍了如何在索引0处查找新行字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:



%身体

家庭是幼儿期的中心社交背景

行为\ cite {dishi-sto2007,hengg-etal1998,johns-etal2005}。



家庭管理对于父母来说变得更具挑战性

从童年中期过渡到青春期。通常开发



问题:我需要从字符串%body中提取内容到第一段。使用

Example:

%body
The family is a central socialization context from early childhood
behavior \cite{dishi-sto2007,hengg-etal1998,johns-etal2005}.

Family management becomes more challenging for parents during the
transition from middle childhood to adolescence. Typically developing

Question: I need to the extract the content from the string "%body" to first paragraph. Am using

preg_match( '/%body\\n(.*?)\\n/', $text, $matches ); 

来提取。但是产出是家庭是幼儿时期的中心社会化背景,因为它的所有方面都是如此。那么如何使用正则表达式在索引0处找到\ n字符,以便我可以按段提取。

to extract. But output is "The family is a central socialization context from early childhood" as \n charcter is in all the lines. So how to find the \n character at index 0 using regex, so that I can extract by paragraph.

推荐答案

text,
text,


匹配);
matches );

来提取。但是产出是家庭是幼儿时期的中心社会化背景,因为它的所有方面都是如此。那么如何使用正则表达式在索引0处找到\ n字符,以便我可以按段提取。

to extract. But output is "The family is a central socialization context from early childhood" as \n charcter is in all the lines. So how to find the \n character at index 0 using regex, so that I can extract by paragraph.


而不是正则表达式,尝试 PHP explode()函数 [ ^ ]

Instead of Regex, try the PHP explode() Function[^]
<?php


这篇关于如何在索引0处查找新行字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆