preg_replace href值仅当在其中找不到字符串x时

时间:2016-05-18 11:06:53

标签: php regex

我遇到以下情况的问题

我想用preg_replace替换href值,不知道如何

我有三种类型的链接

1:<a href="http://www.something.com"></a>
2:<a href="smartlink:webview-something"></a>
3:<a href="link/to/something"></a>

我想在链接3上添加域名(http://www.something.com/link/to/something) 但是1和2应保持不变。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

试试这个:

public DateTime Value {
            set {
                bool valueChanged = !DateTime.Equals(this.Value, value);
                // Check for value set here; if we've not set the value yet, it'll be Now, so the second
                // part of the test will fail.
                // So, if userHasSetValue isn't set, we don't care if the value is still the same - and we'll
                // update anyway.
                if (!userHasSetValue || valueChanged) {
                    if ((value < MinDate) || (value > MaxDate)) {
                        throw new ArgumentOutOfRangeException("Value", SR.GetString(SR.InvalidBoundArgument, "Value", FormatDateTime(value), "'MinDate'", "'MaxDate'"));
                    }
}

点击preg_replace
http://www.phpliveregex.com/p/fJ9