如何修复此字符串替换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
最满意答案
您的模型计算两个粒子之间的重力两次:对于第一个粒子,力基于其原始坐标,对于第二个粒子,它基于第一个粒子的更新位置。 这显然违反了牛顿第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.
相关问答
更多-
二维碰撞n体仿真(大量球的快速碰撞检测)(2D colliding n-body simulation (fast Collision Detection for large number of balls))[2022-05-04]
物理模拟的第一步是宽相碰撞检测。 这里有几种方法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 ... -
C#中的N体仿真(N body simulation in C#)[2021-12-20]
您的模型计算两个粒子之间的重力两次:对于第一个粒子,力基于其原始坐标,对于第二个粒子,它基于第一个粒子的更新位置。 这显然违反了牛顿第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 ...
-
C#中的交点仿真(Intersection Simulation in C#)[2023-11-13]
在游戏中通常的做法是通过一个主循环。 您可以按照您提到的方式在WPF中执行此操作 - 创建DispatcherTimer,并在一次调用期间更新所有位置。 创造更多的计时器是不必要的消耗资源几乎没有任何好处。 真正的汽车物理相对复杂,但对于您的用例,您可以使用非常简单的东西。 这篇关于简单而又好看的汽车物理学的文章很棒(也很简短): http : //engineeringdotnet.blogspot.com/2010/04/simple-2d-car-physics-in-games.html The u ... -
电网仿真库(Library for electrical network simulation)[2023-09-19]
http://www.thedigitalmachine.net/eispice.html http://www.thedigitalmachine.net/eispice.html -
在MATLAB中使用点数据创建电影,以进行简单的N体仿真(Creating a movie in MATLAB with point data for a simple N-body simulation)[2021-10-20]
首先,您必须为模拟的每个时间步长制作帧(图像)。 由于您有笛卡尔坐标,因此必须将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 ...