Display only a substring of values returned from SPServices SPAutocomplete function

I’m using SPAutocomplete from SPServices because I have a requirement to make a searchable lookup field rather than an OOTB lookup field (drop down menu), as there is potential for thousands of values in the source column. It’s working fine, except it’s displaying “string;#” before the value, and I need only the value to appear for each option.

enter image description here

Here is my code:

<script      src="https://code.jquery.com/jquery-3.3.1.js"      type=text/javascript> </script>  <script      src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.js">     type=text/javascript> </script>   <script type="text/javascript">      $  (document).ready(function () {          $  ().SPServices.SPAutocomplete({             sourceList: "{C9AF367D-2CA1-40EE-B0AE-99CFDSAF6543389}",             sourceColumn: "Reported_x0020_Tracking_x0020_Number",             columnName: "Tracking Number",             ignoreCase: true,             filterType: "Contains",             numChars: 1,             uniqueVals: true,             slideDownSpeed: 'fast'         });          $  ("select[id^='Tracking_x0020_Number'] > option").each(function () {         {         $  (this).val(this.substring(9));         }          });      });  </script> 

I can’t get the each function to display only the substring I want properly. I am beginner level with JQuery (actually a data scientist – but have been required to create custom lists for data collection purposes).

Any help is greatly appreciated!

Suffix-automaton Largest common substring of multiple strings

Can anyone help with understanding how to solve “Largest common substring of multiple strings” problem with usage of Suffix-automaton?

I’ve found this a really good article about SA . But unfortunately it’s pretty hard to understand how it works for multiple strings without a code snippet.

As I see it should be done in a way:

  1. for each state of string Si find a path which leads to delimiter Di (but each state of string Si has such path)

  2. then include only chars from which there is a path to all delimiters (each char from the first string, but none from the last)

Seems like I’m definitely missing something in the explanation.

Any help is appreciated)

The field “substring” on type “Microsoft.SharePoint.Workflow.ROOT” does not exist or is not accessible

Creating a list workflow on SharePoint Designer 2013. My workflow shows no errors but after attempting to publish, comes back with “Errors were found when compiling the workflow. The workflow files were saved but cannot be run.” Additional details stated, “(0, 0) Activity ‘ID8090’ validation failed: Property “Condition” has invalid value. Condition expression is invalid. The field “substring” on type “Microsoft.SharePoint.Workflow.ROOT” does not exist or is not accessible.)”

What is or where can I find this error to fix it?

Thank you

Python program to get the longest substring

Given a word the program outputs the length of the longest substring with the same letters. For example:

  • long_repeat(‘sdsffffse’) == 4
  • long_repeat(‘ddvvrwwwrggg’) == 3
  • long_repeat(‘abababaab’) == 2
  • long_repeat(”) == 0

The code is:

def long_repeat(line):  substrings = [] current_substring = "" for i, letter in enumerate(line):     if i == 0:         current_substring = letter     else:         if letter == current_substring[len(current_substring) - 1]:             current_substring += letter             if(i == len(line)- 1):                 substrings.append(current_substring)         else:             substrings.append(current_substring)             current_substring = letter  lengths = [] for substring in substrings:     lengths.append(len(substring))  if len(lengths) > 0:     return  max(lengths) else:     return 0 

What could be improved?

How do I use a sub-string of a field?

How do I convert SELECT title , SUBSTRING(title,13,4) as num FROM node_field_data ORDER BY ABS(num) to the format for Drupal 8?

I tried this code.

 $  query = $  db->select('node_field_data', 'nfd')   ->extend('\Drupal\Core\Database\Query\TableSortExtender')   ->extend('\Drupal\Core\Database\Query\PagerSelectExtender');   $  query->limit('50');   $  query->fields('nfd',array('title',substring(title,13,4) as num,'changed','nid'));  ->orderBy('num', 'ASC')    

HOW TO CREATE A SUBSTRING FROM A STRING FOR AN ARRAY OF STRINGS

say for example i have a string array as such :

string = { ‘feels’ , ‘heels’, ‘never’, ‘mean’};

How is it possible to find all sub strings containing more than 3 letters of each word in the array? for example,

Sub Strings of first word ‘feels’ would be = feel, feels, eels.

Sub Strings of second word ‘heels’ would be = heel, heels, eels.

Sub Strings of second word ‘heels’ would be = neve, never, ever.

can someone kindly help me with the logic?

Longest Substring Without Repeating Characters in JS

The task

is taken from leetcode

Given a string, find the length of the longest substring without repeating characters.

Example 1:

Input: “abcabcbb”

Output: 3

Explanation: The answer is “abc”, with the length of 3.

Example 2:

Input: “bbbbb”

Output: 1

Explanation: The answer is “b”, with the length of 1.

Example 3:

Input: “pwwkew”

Output: 3

Explanation: The answer is “wke”, with the length of 3. Note that the answer must be a substring, “pwke” is a subsequence and not a substring.

My solution

var lengthOfLongestSubstring = function(s) {     const len = s.length;     if (len < 2) { return len; }     let res = [];     let tmp = [];     [...s].forEach(x => {       if (tmp.includes(x)) {         tmp = [...tmp.slice(tmp.findIndex(y => y === x ) + 1)];       }       tmp.push(x);           if (tmp.length > res.length) { res = tmp; }     });   return res.length; }; 

Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack


Algorithm: Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack.

Example:

[['a','A','@'], ['b','B','8'], ['c','(','[']] 

This list can be combined by selecting from each of the subarrays in order, such as:

abc, ab(, ab[, Abc, Ab( etc.

Are any of these combinations substrings of the search string?

"123 easy as Ab(" # True "123 easy as Abb" # False "123 easy as @b(" # True "123 easy as Abc" # False 

Python 3

combos = [['a','A','@'], ['b','B','8'], ['c','(','[']] search = "123 easy as Ab(" # True  def find_mutated_string(offset, combos, search):     for i, char in enumerate(search):         for mutant in combos[offset]:             if mutant == char:                 if len(combos) == (offset+1):                     # Last letter combo found                     return True                 else:                     return find_mutated_string(offset+1, combos, search[i+1:])     # Didn't find mutant char in search string     return False  print(find_mutated_string(0, combos, search)) 

Buscar substring exacto en una frase

primera vez que publico espero hacerlo bien, me propuse hacer el siguiente ejercicio que estaba propuesto para desarrollarse en java pero yo lo quiero hacer en python:

Un programa que permita ingresar una palabra (a buscar) y tantas frases como el usuario quiera (para terminar debe ingresar FIN). Osea, buscar un string exacto en cada frase y si la contiene debe ser impresa junto con las demás frases que contengan la palabra a buscar ej:

perro

El perro come su hueso.
Hoy hace mucho calor en la ciudad.
José y su perro caminan por la costanera.
Josefina tiene dos perros de peluche en su habitación.

El programa sólo debe imprimir en consola las oraciones “El perro come su hueso.” y “José y su perro caminan por la costanera.”

    palabra=input()     bandera=0     contadorDiferencias=0     v=[] #vector para ir guardando las frases que cumplan la condicion     while True:         f=input()         bandera=f.find(palabra)          if f[len(f)-1]==palabra[len(palabra)-1]: #si está la palabra y la ultima letra de la frase es igual a la ultima de la palabra:             for i in range(len(palabra)): #verificará si coincide palabra por palabra el string                 if palabra[i] == f[bandera]:                                                             bandera=bandera+1                 else:                     contadorDiferencias=contadorDiferencias+1 #en caso de no haber coincidencia lo aumentamos                     bandera=bandera+1              if contadorDiferencias == 0:                 v.append(f)          elif f[bandera+len(palabra)]== " " or f[bandera+len(palabra)]== "." or f[bandera+len(palabra)]==",":        #para casos en los que el usuario haya agregado algo más                  for i in range(len(palabra)):                 if palabra[i] == f[bandera]:                                                             bandera=bandera+1                 else:                     contadorDiferencias=contadorDiferencias+1                     bandera=bandera+1              if contadorDiferencias == 0: #si se encontró una diferencia agregarla al vector                 v.append(f)          if f == "FIN":             break      for i in range(len(v)):         print(v[i]) 

Al ejecutar el problema está aqui, me dice que está fuera de rango el index (IndexError: string index out of range):

elif f[bandera+len(palabra)]== " " or f[bandera+len(palabra)]== "." or f[bandera+len(palabra)]==",": 

Esto es lo que no entiendo, si con el primer if tomo los casos en los que la ultima letra de la frase es la ultima letra de la palabra, en el elif solo entran los casos en los que hay “algo” despues de la palabra entonces por qué estaría fuera de rango el indice? La verdad estoy muy enredado, saludos