I have a string that might look like this:
searchText = search:kind:(reports) unit.id:(("CATS (WILLIAMS)"~1) OR ("DOGS (JAMES)"~1))
I need to extact any values that may exist in the quotation marks so in this case it would be:
CATS (WILLIAMS)
and DOGS (JAMES)
Not sure I understand how using indexOf and subString will get me a text string since they depend on integer values... Can someone show me some examples of how this might be done? Thanks
Ok figured out the basics, but I need it to extract every value in " " not just the first instance. The below extacts the value then converts the name into an id then replaces the name with an id, but ONLY does the first instance.
String unitIdStart = "\"";
String unitIdEnd = "\"~";
int unitIdStartIndex = searchText.indexOf(unitIdStart);
if( unitIdStartIndex != -1 ) {
int unitIdEndIndex = searchText.indexOf(unitIdEnd, unitIdStartIndex);
if( unitIdEndIndex != -1 );
{
String unitName = searchText.substring(unitIdStartIndex+1, unitIdEndIndex);
Unit backToId = UnitRepository.getIdFromName(unitName);
String unitId = backToId.getId().toString();
String searchTextWithUnitId = searchText.replace(unitName, unitId);