• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Text Parser - Extract Pattern - Not extracting the values i want

Status
Not open for further replies.

nomisite

Member
Hi,

I have tested out my regex with https://regex101.com/ and it works

but when I try here, it doesnt work. What I intend to do is making "maximizing-benefits-by-meeting-the-essential-requirements-of-chat-gpt-2" become "maximizing-benefits-by-meeting-the-essential-requirements-of-chat-gpt"

My regex is as follow: ^[a-zA-Z-]+(?<!-)$

Can you tell me what went wrong? Thanks:

pabbly issue.png
 
P

Pabblymember11

Guest
Hey @nomisite

Can you please share the use case that you are trying to perform here, also in place of this regex you can refer to the use Code by Pabbly action step with JS code -

function isValidString(str) { const regex = /^[a-zA-Z]+(?:-[a-zA-Z]+)*$/; return regex.test(str) && !str.endsWith("-"); } // Example usage: const testString1 = "abc-def"; // Valid const testString2 = "abc-def-"; // Invalid const testString3 = "abc-defg"; // Valid const testString4 = "abc-"; // Invalid return(isValidString(testString1)); // Output: 1 return(isValidString(testString2)); // Output: 0 return(isValidString(testString3)); // Output: 1 return(isValidString(testString4)); // Output: 0

2024-02-13_16h25_55.png
 

nomisite

Member
Hi,

I got it already, but i still need some help here~! What I did is like this:

function extractString(inputString) {
// Define a regular expression pattern to match the last dash and number
var regexPattern = /-\d+$/;

// Check if the inputString ends with a dash followed by a number
if (regexPattern.test(inputString)) {
// Remove the last dash and number from the inputString
var extractedString = inputString.replace(/-\d+$/, '');
return extractedString;
} else {
// If no dash and number found at the end, return the original string
return inputString;
}
}

// Example usage:
const testString1 = "2. 1 Slug : maximizing-benefits-by-meeting-the-essential-requirements-of-chat-gpt-2"; // Valid
const testString2 = "2. 2 Slug : character-limitation-in-chatgpt-2"; // Invalid
const testString3 = "2. 2 Slug : character-limitation-in-chatgpt-2"; // Valid
const testString4 = "2. 3 Slug : utilizing-tome-ai-a-guide-2"; // Invalid
return(extractString(testString1)); // Output: 1
return(extractString(testString2)); // Output: 0
return(extractString(testString3)); // Output: 1
return(extractString(testString4)); // Output: 0

My question is, how can i output all 4 lines here? I only receive one output, just like this screenshot here:

1707897506570.png


Thanks
 
P

Pabblymember11

Guest
Try this -

function isValidString(str) {
const regex = /^[a-zA-Z]+(?:-[a-zA-Z]+)*$/;
return regex.test(str) && !str.endsWith("-");
}

// Example usage:
const testString1 = "abc-def"; // Valid
const testString2 = "abc-def-"; // Invalid
const testString3 = "abc-defg"; // Valid
const testString4 = "abc-"; // Invalid

console.log(isValidString(testString1)); // Output: true
 

nomisite

Member
Hi,

What I mean is, I want to have 4 outputs from 4 strings I passed in.

1707989197229.png


Currently if I put return and console.log, it will give me 2 output. If i put 2 console.log, it will put all output the Value in the same Logs box.

And I cannot select it individually on the next step. Somemore if it is console.log, it has the date and info thingy. I do not want that, i want a clean string like the Value in the Output box.

1707989262668.png


Is this possible? Or do I just need to do this code 4 times in the workflow so that I can get all string cleanly?

Thanks
 
P

Pabblymember11

Guest
Hey @nomisite
Is this possible? Or do I just need to do this code 4 times in the workflow so that I can get all string cleanly?
You can use it 4 times for your use case or you can optimize the code on OpenAI according to your customization.
 
Status
Not open for further replies.
Top