首页 \ 问答 \ 如何修复此字符串替换php问题?(How to fix this string replace php problem?)

如何修复此字符串替换php问题?(How to fix this string replace php problem?)

我想用链接替换单词(不包括:,。。stc。)。 我怎样才能做到这一点?

<?php
$string = "wordey; string, boom";
$string = preg_replace("/[^a-z]/i", "<a href='x'>/[^a-z]/i</a>", $string); //??
echo $string; // <a href='wordey'>wordey</a>; <a href='string'>string</a>, <a href='boom'>boom</a>
?>

请注意; ,。 - 等等很重要。


I want to replace the words(excluding: , ; . stc.) with links. How can I do this?

<?php
$string = "wordey; string, boom";
$string = preg_replace("/[^a-z]/i", "<a href='x'>/[^a-z]/i</a>", $string); //??
echo $string; // <a href='wordey'>wordey</a>; <a href='string'>string</a>, <a href='boom'>boom</a>
?>

Please note that the ; , . - etc are important.


原文:https://stackoverflow.com/questions/6946757
更新时间:2023-03-22 15:03

最满意答案

您的模型计算两个粒子之间的重力两次:对于第一个粒子,力基于其原始坐标,对于第二个粒子,它基于第一个粒子的更新位置。 这显然违反了牛顿第3定律。 您必须在更新之前预先计算所有力。


Your model calculates the gravity force between two particles twice: for the first particle the force is based on their original coordinates, and for the second particle it is based on an updated position of the first one. This is a clear violation of the Newton's 3rd law. You must precompute all the forces before any update.

相关问答

更多
  • 物理模拟的第一步是宽相碰撞检测。 这里有几种方法http://http.developer.nvidia.com/GPUGems3/gpugems3_ch32.html,但是两个基本方法是空间分区,将对象分成网格,或者排序和扫描,其中包括排序沿着两个轴的所有物体。 This first step in physics simulation is the broad-phase collision detection. There are several approaches outlined here ht ...
  • 您的模型计算两个粒子之间的重力两次:对于第一个粒子,力基于其原始坐标,对于第二个粒子,它基于第一个粒子的更新位置。 这显然违反了牛顿第3定律。 您必须在更新之前预先计算所有力。 Your model calculates the gravity force between two particles twice: for the first particle the force is based on their original coordinates, and for the second partic ...
  • 确保您的消息对象不为null,方法是检查null OpenPop.Mime.Message message = client.GetMessage(i); //Check you message is not null if(message != null){ OpenPop.Mime.MessagePart messagePart = message.MessagePart.MessageParts[1]; string test = messagePart.BodyEncoding.G ...
  • 您没有初始化变量。 例如这里: double fy; for (int i = 0; i <= 3; i++){ if (bodies[i].x == aap.x && bodies[i].y == aap.y && bodies[i].vx == aap.vx && bodies[i].vy == aap.vy) {;} else { fy += aap.p(x1,y1,bodies[i]); } 你应该做 double fy = 0; You didn't initiali ...
  • 在游戏中通常的做法是通过一个主循环。 您可以按照您提到的方式在WPF中执行此操作 - 创建DispatcherTimer,并在一次调用期间更新所有位置。 创造更多的计时器是不必要的消耗资源几乎没有任何好处。 真正的汽车物理相对复杂,但对于您的用例,您可以使用非常简单的东西。 这篇关于简单而又好看的汽车物理学的文章很棒(也很简短): http : //engineeringdotnet.blogspot.com/2010/04/simple-2d-car-physics-in-games.html The u ...
  • http://www.thedigitalmachine.net/eispice.html http://www.thedigitalmachine.net/eispice.html
  • 首先,您必须为模拟的每个时间步长制作帧(图像)。 由于您有笛卡尔坐标,因此必须将x和y坐标转换为像素索引,并从中创建图像矩阵。 有关如何执行此操作的示例,请参阅我对相关问题的回答 。 您还可以修改代码以使您的点大于像素,具有形状等,可能使用strel或[a,b,~] = sphere(N) 。 获得帧后,您可以在MATLAB中轻松制作AVI文件(未压缩或MPEG): aviOutput = fullfile('path','to','file.avi'); aviobj = VideoWriter(aviO ...
  • 辅助类旨在涵盖原始VB'Val'所涵盖的一些奇怪情况。 如果您对'Val'的使用不依赖于原始的VB特性,那么您可以用简单的TryParse替换。 请注意,'Val'比简单的TryParse做得更多。 您还可以检查原始的VB'Val'代码,以确切了解它正在做什么 - 可能甚至比辅助类正在做的更多。 The helper class is intended to cover some strange cases that the original VB 'Val' covers. If your usage o ...
  • 您需要连接到本地代码。 你可以把它放在一个DLL中并且拼写。 好的,当你不经常转换和界面很薄时。 最灵活和最快速的解决方案是用C ++ / CLI语言编写一个ref类包装器。 看一下这篇杂志上的文章 。 最后但并非最不重要的,你真的应该剖析C#代码。 8的因素是相当过分的。 直到你至少有一半的想法为什么这么慢,不要开始。 你不想在C ++代码中复制原因,这会毁了一周的工作。 并提防错误的本能。 64位代码实际上并不快,它通常比x86代码慢一点。 它有一堆额外的寄存器非常好。 但是所有的指针都是大小的两倍,你 ...
  • 问题不在GetGravEffect方法中(它给出了正确的结果),但在Update方法中。 它完全忽略了物理定律。 您不能对GetGravEffect返回的值求和,并将其视为速度。 GetGravEffect返回一个对象吸引另一个对象的强制。 您必须对这些力进行求和,然后执行其他计算,包括惯性,加速度和时间来计算结果速度。 同时将X和Y转换为int也不是一个好主意,因为你会失去很多准确性,特别是对于慢速。 使用以下更正的方法,它很有效: public void Update() { V ...

相关文章

更多

最新问答

更多
  • 您如何使用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)