功能需求如下:如字符串1为: csdn.net/userprofile/Jack.aspx 对应: csdn.net/index.aspx?type=userprofile&userID=Jack
字符串1为: csdn.net/login.aspx 对应: csdn.net/index.aspx?type=login本意是想这样:
{0}/{1}/{2}.aspx --> {0}/index.aspx?type={1}&userID={2}
{0}/{1}.aspx --> {0}/index.aspx?type={1}可以怎么实现呢?
字符串1为: csdn.net/login.aspx 对应: csdn.net/index.aspx?type=login本意是想这样:
{0}/{1}/{2}.aspx --> {0}/index.aspx?type={1}&userID={2}
{0}/{1}.aspx --> {0}/index.aspx?type={1}可以怎么实现呢?
解决方案 »
- 在sql查询语句中什么时候用到子查询啊
- 做网站的时候用户表中的数据如何预置?
- javascript 调用WebServices 时,能否传递控件?
- 字符串过滤:只留字母和数字!
- 关于select语句查询数据库的问题?
- 急 ! 关于下拉框的问题
- 请问如何在TextBox的TextMode为Password的情况下,给初始值?
- 在VS2005Bate1中,GridView修改数据后不能保存
- 关于html格式的邮件在foxmail中显示的问题?
- 求助:如何在DataGrid里绑定<textarea></textarea>的数值?急!
- B/S架构无刷新更新页面
- DataTable与ViewState结合实现商品订单问题
可以可以的去添加??
没用吧~~
try {
resultString = Regex.Replace(subjectString, "(.*)/(.*)/(.*).aspx", @"\1/index.aspx?type=\2&userID=\3");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
try {
resultString = Regex.Replace(subjectString, "(.*)/(.*)/(.*).aspx", @"\1/index.aspx?type=\2&userID=\3");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
try {
resultString = Regex.Replace(subjectString, "(.*)/(.*)/(.*).aspx", @"\1/index.aspx?type=\2&userID=\3");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
string strContent = "csdn.net/login.aspx";
Regex re = new Regex(@"(?<info>[^/]*/)((?<type>[^/]*)/)*(?<value>[^\.]*)");
string strInfo = ""; string strType = ""; string strValue = "";
if (re.IsMatch(strContent))
{
Match m = re.Match(strContent);
strInfo = m.Groups["info"].Value.Trim();
strValue = m.Groups["value"].Value.Trim();
if (m.Groups["type"] != null)
{
strType = m.Groups["type"].Value.Trim();
}
}
strContent = strInfo + "index.aspx?" + (strType == "" ? "type=" + strValue : "type=" + strType + "&userID=" + strValue);