在范围内自动递增 URL ID 号
我需要能够在 HTML 文档中执行某种查找和替换操作,其中搜索将查找特定范围内的所有数字。但我需要将每个数字替换为自身的增量。例如,我在页面中有一个链接列表,它们看起来都是这样的:
.../click.asp?aid=702134570
.../click.asp?aid=702134571
.../click.asp?aid=702134572
每天这些链接都需要使用为我们自动生成的新链接进行更新。 URL 中唯一发生变化的部分是末尾的数字,并且它们都会增加相同的数量。因此,如果生成的下一批链接如下所示:
.../click.asp?aid=762184547
.../click.asp?aid=762184548
.../click.asp?aid=762184549
那么每个链接“援助”都会增加 60049977。问题是这个数字每天都会变化,显然它搜索的范围也会变化。我知道 Dreamweaver 查找和替换选项支持正则表达式,我觉得这种方式可能是可行的,但在扩展搜索之后我没有找到任何东西,而且我对正则表达式不够熟悉,不知道要尝试什么。先感谢您。
I need to be able to do a sort of Find and Replace within an HTML document where the search would be for all numbers within a certain range. But I need each number to be replace with an increment of itself. For example, I have a list of links within a page that all look like this:
.../click.asp?aid=702134570
.../click.asp?aid=702134571
.../click.asp?aid=702134572
Every day those links need to be updated with new links that are auto generated for us. The only part of the URL that changes are the numbers at the end, and they would all increase by the same amount. So if the next lot of links generated looked like this:
.../click.asp?aid=762184547
.../click.asp?aid=762184548
.../click.asp?aid=762184549
So every link 'aid' would increase by exactly 60049977. The problem is this number would change every day and obviously so would the range it would search within. I know Dreamweaver find and replace option supports regular expressions and I feel that this might be possible this way, but after an extension search I haven't found anything and I'm not familiar enough with regular expressions to know what to try. Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Dreamweaver 中的查找和替换功能应该能够通过搜索 click.asp?aid= 找到您想要更改的链接。
您甚至可以尝试通过选中“使用正则表达式”框并搜索:
click.asp\?aid=\d+
但是,没有任何内置内容可以让您通过添加特定数字来自动替换值。
理论上,您可以在 Dreamweaver 中创建一个命令,该命令允许您使用 JavaScript String.replace() 方法通过适当的调整对源进行直接替换,该方法允许您指定一个函数作为第二个参数,而不是简单的细绳。但要做到这一点,您必须学习如何创建 Dreamweaver 扩展。
正如 Mala 所建议的,这应该是动态生成的,而不是依赖人类每天进行这种更改。
The find and replace functionality within Dreamweaver should be able to find the links you want to change by searching for click.asp?aid=
You could even try to include the trailing numbers by checking the "Use regular expression" box and searching for:
click.asp\?aid=\d+
However, there isn't anything built in that will allow you to automatically replace the values by adding a specific number.
Theoretically, you could create a command within Dreamweaver that would allow you to do a direct replacement on the source with the appropriate adjustment using the JavaScript String.replace() method that will allow you to specify a function as the second parameter, than a simple string. But to do that, you'd have to learn how to create a Dreamweaver extension.
And as Mala suggests, this should be something that is dynamically generated, not relying on a human to make this change every day.
不要直接分配数字,而是使用一些变量。
您可以使用脚本..
我想这可能有帮助..
Instead of assigning numbers directly, use some variables..
You can use scriptlets..
I think this may help..