Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
82 views

Pure loop in RegEx to find the substrings with condition

I want to share my invention, which allows you to use only one RegEx, which will search for substrings in a string with a certain condition. If you want, call it a RegEx loop that didn't exist before! ...
Raf's user avatar
  • 9
3 votes
1 answer
102 views

Build a dictionary from a string by the extraction of data from all the pairs <TAG|VAL> contained inside the string and clean string from TAGs

I have written code to manage a string and retrieve from it a dictionary which must contain pairs key-value dependent from the string. To be more clear I'll show ...
User051209's user avatar
1 vote
1 answer
160 views

Function, which replaces consecutive white-space with a single white-space

Task-description: Implement a function, which returns a string with all consecutive whites-spaces replaced as a single-space. Example: "a[space][space][space]b[space][space][space]c" shall ...
michael.zech's user avatar
  • 5,002
9 votes
2 answers
992 views

Swift-function which counts the letters, numbers, spaces, special chars in a given string

Task description: Write a function, which counts the letters, spaces, number and special characters in string. My implementation: ...
michael.zech's user avatar
  • 5,002
4 votes
4 answers
2k views

Matching words from a text with a big list of keywords in Python

I implemented the following code to retrieve medication names from a given text (prescription_text in the code). It works by matching words in the text with a list ...
cuzureau's user avatar
  • 191
4 votes
4 answers
3k views

A function that uses a regex to parse date and time and returns a datetime object

The code works, but I think can be simplified, I don't know which specific steps, but my version seems to me quite complicated I build a function that takes a specific string format and returns a <...
Andrea Ciufo's user avatar
1 vote
2 answers
328 views

Replacing banned words from a given text

The following algorithm is used to find a word from Blacklisted words in a string (called text) and replace these words with censored text, as shown in the example. Example: ...
TomaszOleszko's user avatar
4 votes
2 answers
1k views

Add a number to a file name if does not exist or increase the number if it exist

I'm currently working on a solution to add a number to a file name if the number does not exist or increase de number by one if the number exist. For instance if you input "filename.jpeg" ...
Mario's user avatar
  • 41
2 votes
1 answer
332 views

Text splitter using Regular Expressions in Python

I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list. I had an idea ...
JackWeir's user avatar
2 votes
1 answer
261 views

Extract regular words from string but retain all other elements and record their type

This snippet processes every regular (\w+) word in a text and reinserts the processed version: ...
Alex Povel's user avatar
  • 1,226
3 votes
3 answers
400 views

Regex to extract portions of string about shipment

The Problem I'll be extracting up to 4 parts of a String that come from user-input. All 4 parts need to be in order i.e. (1-4) below in that order The first capturing group is required and the last ...
user2402616's user avatar
2 votes
1 answer
339 views

Find if a dataset of words contains any words containing all vowels by using exactly 5 calls to str_detect

Take the words dataset from stringr. An R4DS exercise challenges the reader to check if there are any words in that dataset that ...
J. Mini's user avatar
  • 137
2 votes
1 answer
71 views

String formatting

My requirement is to format the input values to a particular format as "##.###/##.###" Example - My input value can have alphabets, alphanumeric, numeric Expired -- > if alphabet, output ...
user241512's user avatar
2 votes
0 answers
113 views

Is there a better pattern to match those words with regex?

Hello StackExchange community, I am curious if there is a better solution than mine for this exercise below: Enter a regex that matches all the items in the first column (positive examples) but none ...
Spiros Gkogkas's user avatar
2 votes
2 answers
923 views

Replace string based on multiple rules, don't replace same section twice

Given a 2-column CSV dictionary file that contains translation of certain words, this c# code needs to replace the first occurrence of a word in the dictionary. Once a segment of string has been ...
A_V's user avatar
  • 183

15 30 50 per page
1
2 3 4 5
9