我對RegExp非常陌生。我想要做的是:Javascript RegExp - 匹配字符串並替換
我有這個原始的查詢條件。
var strQuery = "AND i.CreatedDate BETWEEN CAST('01/01/2014' AS Date) " +
"AND DATEADD(Day, 1, CAST('01/01/2015' AS DATE)) " +
"AND e.User_ID IN (-1, 1234, 3433, 9999) " +
"AND i.STATUS IN ('Completed') AND o.Type IN ('Production') "
現在,查找字符串「e.User_ID IN(」然後括號(之間更換任何東西)與新的ID字符串,例如。
var newUserIDs = "8888, 3333, 4444"
// After search and replace using RegExp.
var strQuery = "AND i.CreatedDate BETWEEN CAST('01/01/2014' AS Date) " +
"AND DATEADD(Day, 1, CAST('01/01/2015' AS DATE)) " +
"AND e.User_ID IN (8888, 3333, 4444) " +
"AND i.STATUS IN ('Completed') AND o.Type IN ('Production') "
請幫助。讓我知道如果我不清楚,因爲我事先是新來這個。 感謝。
爲什麼你認爲你需要這個目的的正則表達式? – 2016-03-15 16:41:54
兩個原因:(1)原始查詢條件的User_ID IN()內的長度ID可以改變; (2)我想學習RegExp。謝謝 – Milacay
標記我的帖子不清楚的人不是一個好人。我只是想學習......所以不要那樣。 – Milacay