Questions tagged [last-occurrence]

The last occurrence is the first occurrence starting backwards. Used for questions related to finding the last occurrence of specified data in a data set, matching the last occurrence of a pattern match from a string, or referencing the previously found occurrences.

The last occurrence is the first occurrence starting backwards. Used for questions related to finding the last occurrence of specified data in a data set, matching the last occurrence of a pattern match from a string, or referencing the previously found occurrences.

50 questions
0
votes
1 answer

How to replace the last occurrence of a part of a search string in Python

I have the following string and want to replace the last comma with an "&". I want to do it with Regex, also if it could be done without Regex. This is my example code. mystring = "a, b, c, d" print(re.sub(r", \w$", " & ", mystring)) # this gives…
kame
  • 20,848
  • 33
  • 104
  • 159
0
votes
2 answers

Remove duplicate subarrays based on identifying data respectively retaining the last occurring duplicates

I get the following data from an api query and I need to remove sets of data with duplicate employee id values and retain the last occurring dataset. $holiday_array = [ [ 'employee' => [ 'id' => 456062 ], …
0
votes
1 answer

Return last occurence of search term in python3

I have a log file, that can be very long 2021-02-26 12:49:06.982823 API Get_balance 2021-02-26 12:49:06.983400 FILE Updated_balance /home/balance/balance26022021.json 2021-02-26 12:49:36.426180 INIT Analyst starting up... 2021-02-26 12:49:36.426312…
scandalous
  • 912
  • 5
  • 14
  • 25
0
votes
1 answer

if else loop to create a new categorical variable

i would like to get a new variable lastocc with the values 1 and 2. the variable lastocc should show for each word if its last occurrence was shown also in the same color or not. So, in case when the particular word was shown now and previous time…
0
votes
3 answers

Find the last occurrence using Regular Expressions

I'm a regex newbie, please help me out. The string below occurs in one document: not_unique\">20,000 miles under sea I need to extract the number. The sequence "not_unique" is not unique and may occur in the whole document several times before…
Karen Tamrazyan
  • 157
  • 2
  • 12
0
votes
4 answers

Finding last occurrence of a character in a list of lists

I'm writing a function that needs to return the row, and column of the last occurrence of a certain character in a list of lists. If the character isn't in the list of lists the function should return None. The function ignores or skips the first…
n00bprogrammer22
  • 187
  • 5
  • 12
0
votes
1 answer

How to flag occurrences on multiple conditions in Teradata

I am struggling to achieve what I describe below, I hope someone could help. I have a data set looks like below in Teradata. And I need to set a flag to identify for calls (ignore anonymous) that called in the past, hung up, then called again…
Mixer
  • 183
  • 2
  • 7
  • 15
0
votes
2 answers

Bash get last sentence in line

assume, we got the following variable containing a string: text="All of this is one line. But it consists of multiple sentences. Those are separated by dots. I'd like to get this sentence." I now need the last sentence "I'd like to get this…
chris137
  • 189
  • 1
  • 11
0
votes
2 answers

index() of last occurrence in list in python

In my for loop, I got this code: start = listData.index(datum) + 1 and listData is: listData = ['H66', 'B35', 'L21', 'B35', 'H66', 'J02', 'J04', 'L21', 'J20'] what I want is start = 1,2,3,4,5,6,7,9 but I got start = 1,2,3,2,1,6,7,3…
dPdms
  • 173
  • 2
  • 14
0
votes
1 answer

Grep the last occurence of different elements in a big file

I have a file where different elements are repeated on several lines. My file contains lines like this: 1 $element_(1) 10 $element_(2) 20 $element_(1) 30 $element_(3) 40 $element_(1) 50 $element_(2) 60 $element_(3) 70 $element_(1) I want to get…
0
votes
5 answers

Using regex to find any last occurrence of a word between two delimiters

Suppose I have the following test string: Start_Get_Get_Get_Stop_Start_Get_Get_Stop_Start_Get_Stop where _ means any characters, eg: StartaGetbbGetcccGetddddStopeeeeeStart.... What I want to extract is any last occurrence of the Get word within…
Jerome
  • 25
  • 4
0
votes
4 answers

Capture the last occurrence of a tag

My text is of the form: some text some text some text My task is to insert a closing tag after the last . In the text,…
afs
  • 167
  • 1
  • 9
0
votes
3 answers

Batch: find last line that starts with character then start reading from there

Good day, I want to know how do I create a batch script that searches through a text file that contains multiple lines that start with *==============. I wish for it to find the last occurrence of a line like this and then only use everything…
0
votes
1 answer

binary search nearest match with last occurrence

I am implementing effective algorithm to search last occurrence of ( the key or nearest match (upper bound)). So far, i got this. long bin_search_closest_match_last_occurance ( long * lArray, long sizeArray, long lnumber) { long left, right,…
Rob
  • 708
  • 8
  • 27
0
votes
3 answers

Locating last occurrence of char in a string using pointer (C language)

Function locates the last occurrence of ch in the string pointed to by s. It returns a pointer to the character, or a null pointer if ch does not exist in the string. I'm trying to write the function without using string library functions. This is…
unintendedjoy
  • 281
  • 2
  • 10
  • 18