Coding with OpenAI

After registered yourself…:japanese_ogre:

if xojo uses chatgpt (paid) API, you’d only have to register at xojo forum…

we could even get rid of @Kem_Tekinay

write a xojo program to filter a sample text to remove spaces using regex

Here is an example program in Xojo that uses regular expressions to remove spaces from a sample text:

Dim sampleText As String = "This is a sample text with spaces."

Dim regex As New RegEx
regex.Pattern = "\s" ' \s matches any whitespace character (spaces, tabs, newlines, etc.)
sampleText = regex.Replace(sampleText, "") ' Replace all whitespace characters with an empty string

MsgBox(sampleText) ' Output: "Thisisasampletextwithspaces."

In this example, the RegEx class is used to create a regular expression pattern that matches any whitespace character (\s). The Replace method is then used to replace all occurrences of this pattern with an empty string in the sampleText variable. The modified text is then displayed in a message box.

the main difficulty still would be how to describe what you want to do in natural language so that chatGPT undderstands you…

2 Likes

Well, in the end, we will all be out of job (no joke). I truly believe that.

Except the pattern given is wrong, so there’s that.

2 Likes

seems to work ?

2 Likes

Yes, because the pattern also matches spaces along with all other whitespace, but the request was for a pattern that matches spaces only.

seems we still need you after all ? :wink:

That’s all I’m saying.

Seriously, this is a difference. I said the pattern is wrong because, strictly speaking, it is, even though it might be exactly what’s needed. A person with experience would know to ask before offering a suggestion. “Do you want to eliminate just spaces, spaces and tabs, or all whitespace?” The AI didn’t “know” to do that.

it’s not an AI strictly speaking, it needs to be guided through the conceptual process

modify it to remove all spaces and tabs

Here is an example program in Xojo that uses regular expressions to remove spaces and tabs from a sample text:

Dim sampleText As String = "This is a sample text with spaces and tabs."

Dim regex As New RegEx
regex.Pattern = "[ \t]+" ' [] is used to match any of the characters inside it, here " " and "\t"
sampleText = regex.Replace(sampleText, "") ' Replace all matched characters with an empty string

MsgBox(sampleText) ' Output: "Thisisasampletextwithspacesandtabs."

In this example, the RegEx class is used to create a regular expression pattern that matches one or more spaces and tabs([ \t]+) . The Replace method is then used to replace all occurrences of this pattern with an empty string in the sampleText variable. The modified text is then displayed in a message box.

Try asking to code it in real basic… that works.

hello, what’s this app ?


mind to share ? thanks

@Kem_Tekinay RegexRX
available on the mac app store, worth every penny !

2 Likes

ahhh oki, one can finally understand your joke about kem :wink:

1 Like

This looks amazing! By any chance do you know if there’s anything like this on Windows?

From the first day I got ChatGPT I have been trying to get it to crank out Xojo code. It comes close, but it makes up a bunch of classes and methods that don’t exist.

I find that asking it to write VB6 code comes close enough where I can convert it to Xojo fairly trivially and most importantly, somewhat mindlessly.

There’s a Windows version:

Kem’s RegExRx Download Page

2 Likes

Putting together a tool today to use OpenAI. Whilst I agree with sentiments shared about newbies and reliance on this etc, for those of us who are experienced and recognise that it can be a good start, then with eyes wide open it can be a great help:

Again, all about the right expectations of what it can do for you in my mind.

strange it’s almost good except & and &= aren’t part of xojo language ?

It is strange to see how software developers are so excited about OpenAI, which eventually makes coders redundant. Which at this rate happens sooner than later. Time to look for a new job.