Patrick 310 Posted April 27, 2019 Share Posted April 27, 2019 Hi! I'm pretty ignorant of the search pattern, I want some help with this. Example string: "something #ffffff anothersomething color:#ffffff" I'd like to choose the color codes that don't have the color: word before. (In this example, the first color code) example #ff0000 -> result: true color:#ff0000 -> result: false Link to post
itHyperoX 40 Posted April 27, 2019 Share Posted April 27, 2019 maybe a stupid idea, but string.find ? Link to post
VenomNX 173 Posted April 27, 2019 Share Posted April 27, 2019 10 hours ago, stPatrick said: Hi! I'm pretty ignorant of the search pattern, I want some help with this. Example string: "something #ffffff anothersomething color:#ffffff" I'd like to choose the color codes that don't have the color: word before. (In this example, the first color code) example #ff0000 -> result: true color:#ff0000 -> result: false I don't understand ! Do you want to check is the color inside the string ? or what ? Link to post
ShayF2 53 Posted April 28, 2019 Share Posted April 28, 2019 (edited) local _output = outputChatBox function outputChatBox(text, ...) if string.find(text, 'color:#') then string.gsub(text, 'color:', '') end return _output(text, unpack(arg)) end Edited April 28, 2019 by Pollo Link to post
Zorgman 116 Posted April 30, 2019 Share Posted April 30, 2019 (edited) Is this what you mean? https://regex101.com/r/wHUrZs/2 (?<!color:)(#\S{6})(?=\s) Edited April 30, 2019 by Zorgman updated expression with a lookahead 1 Link to post
Patrick 310 Posted April 30, 2019 Author Share Posted April 30, 2019 9 hours ago, Zorgman said: Is this what you mean? https://regex101.com/r/wHUrZs/2 (?<!color:)(#\S{6})(?=\s) Ahh, yes! But have a problem, because this regex, and MTA can't use it. (or am I wrong?) Link to post
Patrick 310 Posted April 30, 2019 Author Share Posted April 30, 2019 25 minutes ago, stPatrick said: Ahh, yes! But have a problem, because this regex, and MTA can't use it. (or am I wrong?) I didn't say anything. Thanks the help, again. (Replace with regex: https://wiki.multitheftauto.com/wiki/PregReplace) Link to post
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now