Create query instead of RegX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I got the following RegX and need help how to use or transfer it for an encoded query to get all matching CI names (server names with class "Windows Server" from table "cmdb_ci_server").
[i,I][m,M][c,C][i,I,t,T,p,P][e,E]0[0,d,D,f,F,a,A,p,P] [0,a,A,b,B][0-9][a,A][0-9][0-9]
Example for a result (server name): imcie0000a00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I don't know that you can use regex in a GlideRecord query, so you may have you loop through all of the class, pushing the matching results to an array.
var matchArr = [];
var svr = new GlideRecord('cmdb_ci_server');
svr.addQuery('sys_class_name', 'cmdb_ci_win_server');
svr.query();
while (svr.next()) {
var regex = new RegExp("[i,I][m,M][c,C][i,I,t,T,p,P][e,E]0[0,d,D,f,F,a,A,p,P] [0,a,A,b,B][0-9][a,A][0-9][0-9]");
if (regex.test(svr.name)) {
matchArr.push(svr.name);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Brad Bowman ,
Regex is working server side script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks for your reply. Unfortunately coding is not my knowledge level. I thought there would be an easier way.
