Unsolved Need Regex Help
-
Have you seen: https://regex101.com/
I got shown that the other day. Looks like it might be of some assistance. -
@nadnerb said in Need Regex Help:
Have you seen: https://regex101.com/
I got shown that the other day. Looks like it might be of some assistance.I'm on regexr.com right now but will take a look at regex101.com in a moment.
-
@dustinb3403 said in Need Regex Help:
Hey all,
I need some help with some regex, which I admittedly never use in my day to day.
The goal is I want to search a list of software across multiple systems and key in on 3 specific names and only list the systems that specifically don't have any of those 3 names.
IE
Computer Name | Application
bobs-pc | Microsoft
bobs-pc | Libre
bobs-pc | MyTax
Sarahs-pc | Anti-virus
Sarahs-pc | MyTax
Sarahs-pc | LibreThe output I would like to list
Bobs-pc since it doesn't have Anti-Virus and Sarahs-PC because it doesn't have Microsoft.
Anyone able to help me sort this out?
You can also use
grep
for that. An inverted search (-v
) will give you all the lines that doesn't contain your search string.
grep -v searchstring file
And if you have multiple search strings:
grep -v "search1\|search2\|search3" file
or
grep -v -E "search1|search2|search3" file
Or maybe not when I closer at your file.
You will actually not be able do this with grep or regex or any other simple utility in a simple way.
You will need a script for this. -
@pete-s I can't use grep for this specific function as I'm limited regex or known string searching only through BrightGauge.
-
The regex inverse match is
\b(?!:Microsoft|Libre|MyTax)\b
But this will list literally every other piece of software found, and not the exclusions of "I've not found this software on "Bobs-pc" or on "Sarahs-pc"
-
@dustinb3403 said in Need Regex Help:
@pete-s I can't use grep for this specific function as I'm limited regex or known string searching only through BrightGauge.
If you can't make scripts to massage the data in BrightGauge, I don't think it's possible.
-
@pete-s said in Need Regex Help:
@dustinb3403 said in Need Regex Help:
@pete-s I can't use grep for this specific function as I'm limited regex or known string searching only through BrightGauge.
If you can't make scripts to massage the data in BrightGauge, I don't think it's possible.
That's kind of what I'm feeling. . . but hopes and prayers I can pull something out of my hat. . .
-
Is there anyway to pull the data out so you can use the tools you want?
-
@dashrender said in Need Regex Help:
Is there anyway to pull the data out so you can use the tools you want?
I want to use BrightGauge because I dont want to have to handle the data on an on-going basis. But yes I could export the data, and filter it down to show me just the "These don't have that" in excel which, that is actually already done.
But its still incredibly annoying to have to review.
The end goal is to have a list of systems that are simply lacking one piece of software or another, and to not have to view everything other piece of software with it. So that the lacking software can be installed.
-
@dustinb3403 said in Need Regex Help:
@dashrender said in Need Regex Help:
Is there anyway to pull the data out so you can use the tools you want?
I want to use BrightGauge because I dont want to have to handle the data on an on-going basis. But yes I could export the data, and filter it down to show me just the "These don't have that" in excel which, that is actually already done.
But its still incredibly annoying to have to review.
The end goal is to have a list of systems that are simply lacking one piece of software or another, and to not have to view everything other piece of software with it. So that the lacking software can be installed.
You could pull the data same as BrightGauge does, have a script do something to it and then send it into BrightGauge but it's another level of difficulty.
Have you contacted support? They might have another way of accomplishing it.
-
-
@dustinb3403 said in Need Regex Help:
I need some help with some regex,
Every tool has its own regex. Which regex do you need?
-
@scottalanmiller PostreSQL regex
-
So nothing?
-
@dustinb3403 said in Need Regex Help:
@scottalanmiller PostreSQL regex
Oh wow, I've never used regex in a database before. No idea of that syntax or where/when you'd use it.
-
@scottalanmiller said in Need Regex Help:
@dustinb3403 said in Need Regex Help:
@scottalanmiller PostreSQL regex
Oh wow, I've never used regex in a database before. No idea of that syntax or where/when you'd use it.
It either used for string manipulation or string matching.
From the top of my head with syntax errors included.
For example manipulating strings (convert email to domain name)
select name, regexp_match(email,'.+@(.+)') as domain from customers
For example matching to a simple regexp (all customers that have the has John somewhere in their name):
select * from customers where customer_name ~ 'John'
-
@dustinb3403 said in Need Regex Help:
@scottalanmiller PostreSQL regex
It's easy to solve this problem with SQL - if that is a possibility.
You just need to use a subquery.I'm assuming a table that contains one column with computer name and another with software installed. One row for each software installed.
For example a query to find all computers that have the software installed:
select computer_name from yourtable where software_installed='Microsoft' or software_installed='Anti-virus' group by computer_name
Now we'll use that as a subquery to show all the computers that doesn't have the software installed:
select computer_name from yourtable where computer_name<>( select computer_name from yourtable where software_installed='Microsoft' or software_installed='Anti-virus' group by computer_name ) group by computer_name
The
group by
is to show a computer name just one time, even if you have several rows that contains that name.Note: Syntax errors probably included in my examples.
-
@pete-s Thank you for the help, unfortunately it appears I'm limited to PostgresSQL regex like below or directly selecting the installed software from the list of thousands of items.
\b(?!:Microsoft|Anti-Virus)\b
I have no options for a subquery, at least that I can see at the moment.
-
@dustinb3403 said in Need Regex Help:
@pete-s Thank you for the help, unfortunately it appears I'm limited to PostgresSQL regex like below or directly selecting the installed software from the list of thousands of items.
I have no options for a subquery, at least that I can see at the moment.
Yeah, well you're not going to find a regex solution. Simply because you need to look at several rows of information to determine if the computer has software or not. That's why it's not going to work.
If you could put have all the software into one column then you could use regex to find the rows that doesn't have the software installed. So if you had a string with "Microsoft,Libre,MyTax,Anti-virus " you could use regex on that and it would work fine.
-
@pete-s yeah that is what I'm feeling as well. . . sadly. This really needs to be somehow capable with the tooling, even if I'm not able to implement it.