When I print the text of the task (t.text) I the name of the task + the icons for start/scheduled/due dates + start/scheduled/due dates.
I would like to have only the name of the task, without the icons or the date.
Inspecting the task object seems that thereβs a way to get the start/scheduled/due dates alone but no the task name only.
Any simple solution?
Otherwise Iβm considering to create a function to βcleanβ the text by searching for date formats and replacing with ββ.
---
Date: 1986-06-01
---
#Project/P06
## input
### milestones
### some events
### other events
folder: 07_empty_tasks
filename : dic_19860701
---
Date: 1986-07-01
---
#Project/P07
## input
### main tasks
### some tasks
### other tasks
DQL10_get_the_name_of_the_task_and_TABLE
Summary
Main DQL
Code Name
Data type
Group By
Purposes
Remark
DQL10 _get_the_name _of_the_task _and_TABLE
T.text: a string with a DVIF
no
1.To get the name of the task item(or the list item) without the DVIFs and the start/scheduled/due/completion/created dates from T.text of the file.tasks or L.text of the file.lists where T(or L) is an element of file.tasks(or file.lists)
2.To display the result as a table
1.DVIF=Dataview inline field
2.The DQL10 is based on the the DVJS10 in the topic.
Code DQL10_get_the_name_of_the_task_and_TABLE
Summary_code
title: DQL10_get_the_name_of_the_task_and_TABLE =>1.To get the name of the task item(or the list item) without the DVIFs and the start/scheduled/due/completion/created dates from `T.text` of the file.tasks or `L.text` of the file.lists where `T`(or `L`) is an element of file.tasks(or file.lists) 2.To display the result as a table
collapse: close
icon:
color:
```dataview
TABLE WITHOUT ID
F4_remove_OUTLINKS AS "Task",
T.link AS "Link",
dateformat(T.start, "yyyy-MM-dd") AS "Start date",
dateformat(T.scheduled, "yyyy-MM-dd") AS "Scheduled date",
dateformat(T.due, "yyyy-MM-dd") AS "Due date",
dateformat(T.completion, "yyyy-MM-dd") AS "Completed date",
dateformat(T.created, "yyyy-MM-dd") AS "Created date"
FROM "100_Project/01_dataviewjs/01_by_example/Q86_TaskName/Q86_test_data/03_no_icons"
FLATTEN file.tasks AS T
FLATTEN regexreplace(T.text, "(?:\[[^:\[\]\(\)]+?::.*?\])", "") AS F1_remove_DVIF_IN_SQUARE_BRACKETS
FLATTEN regexreplace(F1_remove_DVIF_IN_SQUARE_BRACKETS, "(?<!%%)(?:\([^:\[\]\(\)]+?::.*?\))(?!%%)", "") AS F2_remove_DVIF_IN_ROUND_BRACKETS
FLATTEN regexreplace(F2_remove_DVIF_IN_ROUND_BRACKETS, "(?<=\s)(?:#[^#\s]+)(?=\s*)", "") AS F3_remove_TAGS
FLATTEN regexreplace(F3_remove_TAGS, "(?<=\s)(?:\[\[([^\[\]]*?)\]\])\s*,*", "") AS F4_remove_OUTLINKS
```
T.text: 1.a string with a DVIF 2.a string with a icon
no
1.To get the name of the task item(or the list item) without the icons and the start/scheduled/due/completion/created dates from T.text of the file.tasks or L.text of the file.lists where T(or L) is an element of file.tasks(or file.lists)
2.To display the result as a table
1.Require the fun_clean function 2.DVIF=Dataview inline field
Notes
Summary
Q1: How to get the Unicode like \u2705 from an icon like ββ?
Q5: How to remove a specific icon with an ISO date like 1986-05-05?
Summary_Q5
A5:
```JS
// T11. define icons:
// #####################################################################
let icons = `add this feature_B β³1986-05-05 #Test/d05 [[Note P]]`;
// F43. define SCHEDULED_DATE_REGEX: ONLY for β³1986-05-05
// #####################################################################
// input:add this feature_B β³1986-05-05 #Test/d05 [[Note P]]
// output:β³1986-05-05
// [Hourglass with Flowing Sand Emoji](https://unicode-table.com/en/23F3/)
// 0x23F3 2022-10-17 by Justdoitcc
// Remarked by Justdoitcc 2022-11-03
const SCHEDULED_DATE_REGEX = /\u{23F3}\s*(\d{4}-\d{2}-\d{2})/u;
// T91. output:
// #####################################################################
dv.span("T91:<br>");
dv.span(icons.replace(SCHEDULED_DATE_REGEX, "")); //
dv.span("<br>");
```
Screenshots(A5)
```md
T91:
add this feature_B #Test/d05 [[Note P]]
```
Q6: How to remove any icon like ββ?
Summary_Q6
A6:
```JS
// T11. define icons:
// #####################################################################
let icons = `β³π β β`;
// T21. define regexp: complicated emojis like β³π β β
// If you need to get rid of complicated emojis,
// you have to remove also additional things like modifiers and etc.
// *#0-9 - are Emoji characters with a text representation by default, per the Unicode Standard.
// #####################################################################
let regexp =
/(?![*#0-9]+)[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]/gu;
// T91. output:
// #####################################################################
dv.span("T91:<br>");
dv.span(icons.replace(regexp, "")); //
dv.span("<br>");
```
Screenshots(A6)
```md
T91:
```
Q7: How to remove any icon with an ISO date like 1986-09-05?
Summary_Q7
A7:
```JS
// T11. define icons:
// #####################################################################
let icons = `add this feature_F π«1986-09-10 β³1986-09-05 π 1986-09-30 β 1986-09-25 β1986-09-01 #Test/d09 [[Note P]] `;
// F51. define ICON_AND_ANY_ISO_DATE_REGEX:
// any icon with an ISO date like β³1986-09-05
// To deal with what F41~F49 do :
// #####################################################################
// input:add this feature_F π«1986-09-10 β³1986-09-05 π 1986-09-30 β 1986-09-25 β1986-09-01 #Test/d09 [[Note P]]
// output:π«1986-09-10 β³1986-09-05 π 1986-09-30 β 1986-09-25 β1986-09-01
// Solutions by grabus at 2021-10-25:
// [How to remove emoji code using javascript?](https://stackoverflow.com/questions/10992921/how-to-remove-emoji-code-using-javascript)
// If you need to get rid of complicated emojis,
// you have to remove also additional things like modifiers and etc.
// *#0-9 - are Emoji characters with a text representation by default, per the Unicode Standard.
const ICON_AND_ANY_ISO_DATE_REGEX =
/(?![*#0-9]+)[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]\s*?(?:\d{4}-\d{2}-\d{2})/gu;
// T91. output:
// #####################################################################
dv.span("T91:<br>");
dv.span(icons.replace(ICON_AND_ANY_ISO_DATE_REGEX, "")); //
dv.span("<br>");
```
Screenshots(A7)
```md
T91:
add this feature_F #Test/d09 [[Note P]]
```
Code DVJS10_get_the_name_of_the_task_and_TABLE
Summary_code
title: DVJS10_get_the_name_of_the_task_and_TABLE => 0.Require the `fun_clean` function 1.To get the name of the task item(or the list item) without the icons and the start/scheduled/due/completion/created dates from `T.text` of the file.tasks or `L.text` of the file.lists where `T`(or `L`) is an element of file.tasks(or file.lists) 2.To display the result as a table
collapse: open
icon:
color:
```dataviewjs
// M10. define today:
// #####################################################################
// const today = dv.date('today'); //org
// M11. define myTasks : gather all relevant Tasks
// #####################################################################
let myTasks = dv
.pages(
'"100_Project/01_dataviewjs/01_by_example/Q86_TaskName/Q86_test_data"'
)
// The following expression can be omitted in the DVJS.
//.where((page) => page.file.tasks.length > 0)
.file.tasks;
// .filter((T) => T.due)
//// .filter((T) => T.date)
// .filter((T) => !T.completed & (T.due < today)) //org
//// .sort((T) => T.date); //org
// M51. TABLE :
// #####################################################################
dv.table(
[
"Task",
"Link",
"Start date",
"Scheduled date",
"Due date",
"Completed date",
"Created date",
],
myTasks.map((T) => [
fun_clean(T.text),
T.link,
dv.func.dateformat(T.start, "yyyy-MM-dd"),
dv.func.dateformat(T.scheduled, "yyyy-MM-dd"),
dv.func.dateformat(T.due, "yyyy-MM-dd"),
dv.func.dateformat(T.completion, "yyyy-MM-dd"),
dv.func.dateformat(T.created, "yyyy-MM-dd"),
])
);
// M90. define fun_clean(): return a string
// To get the name of the task item(or the list item)
// without the icons and the start/scheduled/due/completion/created dates
// from `T.text` of the file.tasks or `L.text` of the file.lists
// where `T`(or `L`) is an element of file.tasks(or file.lists)
// #####################################################################
// version : 2022-11-03 v1.00 Justdoitcc
function fun_clean(text="") {
// F10. define sText:
// #####################################################################
let sText = text;
// F11. check sText :
// #####################################################################
if (sText === "") {
return sText;
}
// F21. define DVIF_IN_SQUARE_BRACKETS_REGEX: [due:: ]
// #####################################################################
// these textual fields [start:: ] [scheduled:: ] [due:: ] [completion:: ] [created:: ]
// input:add this feature_d [start::1986-06-10] [scheduled::1986-06-05] [due::1986-06-30] [completion::1986-06-25] [created::1986-06-01] #Test/d06 #Test/d08
// output:[start::1986-06-10] [scheduled::1986-06-05] [due::1986-06-30] [completion::1986-06-25] [created::1986-06-01]
// Capturing Group (x) + greedy :
// const DVIF_IN_SQUARE_BRACKETS_REGEX = /(\[[^:\[\]\(\)]+::.*\])/;
// Capturing Group (x) + non-greedy :
// const DVIF_IN_SQUARE_BRACKETS_REGEX = /(\[[^:\[\]\(\)]+?::.*?\])/g;
// Non-Capturing Group (?:x) + non-greedy : (For better performance)
const DVIF_IN_SQUARE_BRACKETS_REGEX = /(?:\[[^:\[\]\(\)]+?::.*?\])/gu;
// F23. define DVIF_IN_ROUND_BRACKETS_REGEX: (due:: )
// #####################################################################
// these textual fields (due:: ) (completion:: )
// excluding %%(start:: )%% %%(scheduled:: )%% %%(created::1986-08-01)%%
// input:add this feature_e %%(start::1986-07-10)%% %%(scheduled::1986-07-05)%% (due::1986-07-30) (completion::1986-07-25) %%(created::1986-07-01)%% #Test/d07 [[Note Q]]
// output:(due::1986-07-30) (completion::1986-07-25)
// Capturing Group (x) + greedy :
// const DVIF_IN_ROUND_BRACKETS_REGEX = /(?<!%%)(\([^:\[\]\(\)]+::.*\))(?!%%)/g;
// Negative Lookbehind`(?<!A)` + Non-Capturing Group(?:x) + Negative Lookahead`(?!Z)` : (For better performance)
const DVIF_IN_ROUND_BRACKETS_REGEX = /(?<!%%)(?:\([^:\[\]\(\)]+?::.*?\))(?!%%)/gu;// non-greedy
// F25. define DVIF_HIDDEN_IN_ROUND_BRACKETS_REGEX: %%(due:: )%%
// #####################################################################
// these textual fields %%(start:: )%%
//// const DVIF_HIDDEN_IN_ROUND_BRACKETS_REGEX = /(%%\([^:]+::.*\)%%)/; //greedy
// const DVIF_HIDDEN_IN_ROUND_BRACKETS_REGEX = /(%%\([^:]+?::.*?\)%%)/g; //non-greedy
// F31. define IMPLICIT_FIELDS_TAGS_REGEX: #Test/d06
// #####################################################################
// input:add this feature_d [start::1986-06-10] [scheduled::1986-06-05] [due::1986-06-30] [completion::1986-06-25] [created::1986-06-01] #Test/d06 #Test/d08
// output:#Test/d06 #Test/d08
// Capturing Group (x) :
// const IMPLICIT_FIELDS_TAGS_REGEX = /(?<=\s)(#[^#\s]+)(?=\s*)/g;
// Non-Capturing Group (?:x) : (For better performance)
// const IMPLICIT_FIELDS_TAGS_REGEX = /(?<=\s)(?:#[^#\s]+)(?=\s*)/gu; //FOR DQL10
// Designed in dataview_v0.5.46
// A -tag of the form '#stuff/hello-there'.
// tag: _ => parsimmon_umd_min.exports.seqMap(parsimmon_umd_min.exports.string("#"), parsimmon_umd_min.exports.alt(parsimmon_umd_min.exports.regexp(/[\p{Letter}0-9_/-]/u).desc("text"),
// Positive Lookbehind(?<=A) + Non-Capturing Group(?:x) + Positive Lookahead(?=Z) : (For better performance)
const IMPLICIT_FIELDS_TAGS_REGEX = /(?<=\s)(?:#[\p{Letter}0-9_/-]+)(?=\s*)/gu;
// F33. define IMPLICIT_FIELDS_OUTLINKS_REGEX: [[Note Q]]
// #####################################################################
// input:add this feature_c [start::1986-05-10] [scheduled::1986-05-05] [due::1986-05-30] [completion::1986-05-25] [created::1986-05-01] [[Note Q]] , [[Note J]]
// output:[[Note Q]] , [[Note J]]
// const IMPLICIT_FIELDS_OUTLINKS_REGEX = /(?<=\s)(\[\[.+?\]\])\s*,*/g; //non-greedy
// Designed in dataview_v0.5.46
// An Obsidian link of the form [[<link>]].
// link: _ => parsimmon_umd_min.exports.regexp(/\[\[([^\[\]]*?)\]\]/u, 1)
// Non-Capturing Group (?:x) + non-greedy : (For better performance)
const IMPLICIT_FIELDS_OUTLINKS_REGEX = /(?<=\s)(?:\[\[([^\[\]]*?)\]\])\s*,*/gu;
// F41. define START_DATE_REGEX: π«1986-04-10
// #####################################################################
// input:add this feature_A π«1986-04-10 #Test/d04 [[Note P]] , [[Note Q]]
// output:π«1986-04-10
// [Airplane Departure Emoji](https://unicode-table.com/en/1F6EB/)
// 0x1F6EB 2022-10-17 by Justdoitcc
// Remarked by Justdoitcc 2022-11-03
// const START_DATE_REGEX = /\u{1F6EB}\s*(\d{4}-\d{2}-\d{2})/u;
// F43. define SCHEDULED_DATE_REGEX: β³1986-05-05
// #####################################################################
// input:add this feature_B β³1986-05-05 #Test/d05 [[Note P]]
// output:β³1986-05-05
// [Hourglass with Flowing Sand Emoji](https://unicode-table.com/en/23F3/)
// 0x23F3 2022-10-17 by Justdoitcc
// Remarked by Justdoitcc 2022-11-03
// const SCHEDULED_DATE_REGEX = /\u{23F3}\s*(\d{4}-\d{2}-\d{2})/u;
// F45. define DUE_DATE_REGEX: π 1986-06-30
// #####################################################################
// input:add this feature_C π 1986-06-30 [[Note Q]] [[Note J]]
// output:π 1986-06-30
// [01_Calendar Emoji: 0x1F4C5](https://unicode-table.com/en/1F4C5/)
// 0x1F4C5 2022-10-17 by Justdoitcc
// const DUE_DATE_REGEX = /\u{1F4C5}\s*(\d{4}-\d{2}-\d{2})/u;
// Designed in dataview_v0.5.46
// [01_Calendar Emoji: 0x1F4C5](https://unicode-table.com/en/1F4C5/)
// [02_Tear-Off Calendar (apple):0x1F4C6](https://unicode-table.com/en/1F4C6/)
// [03_Spiral Calendar Pad Emoji (apple): 0x1F5D3](https://unicode-table.com/en/1F5D3/)
// [04_Variation Selector-16 ](https://unicode-table.com/en/FE0F/)
// Remarked by Justdoitcc 2022-11-03
// 0x1F4C5 0x1F4C6 0x1F5D3 0xFE0F
// const DUE_DATE_REGEX = /[\u{1F4C5}\u{1F4C6}\u{1F5D3}\u{FE0F}]{1,}\s*(\d{4}-\d{2}-\d{2})/u;
// F47. define COMPLETION_DATE_REGEX: β 1986-07-25
// #####################################################################
// input:add this feature_D β 1986-07-25 #Test/d07
// output:β 1986-07-25
// Designed in dataview_v0.5.46 (DONE_DATE=COMPLETION_DATE)
// [White Heavy Check Mark Emoji](https://unicode-table.com/en/2705/)
// Remarked by Justdoitcc 2022-11-03
// 0x2705
// const COMPLETION_DATE_REGEX = /\u{2705}\s*(\d{4}-\d{2}-\d{2})/u;
// F49. define CREATED_DATE_REGEX: β1986-08-01
// #####################################################################
// input:add this feature_E β1986-08-01 #Test/d08 #Test/d10
// output:β1986-08-01
// Designed in dataview_v0.5.46
// [Heavy Plus Sign Emoji](https://unicode-table.com/en/2795/)
// Remarked by Justdoitcc 2022-11-03
// 0x2795
// const CREATED_DATE_REGEX = /\u{2795}\s*(\d{4}-\d{2}-\d{2})/u;
// F51. define ICON_AND_ANY_ISO_DATE_REGEX:
// any icon with an ISO date like β³1986-09-05
// To deal with what F41~F49 do :
// #####################################################################
// input:add this feature_F π«1986-09-10 β³1986-09-05 π 1986-09-30 β 1986-09-25 β1986-09-01 #Test/d09 [[Note P]]
// output:π«1986-09-10 β³1986-09-05 π 1986-09-30 β 1986-09-25 β1986-09-01
// Solutions by grabus at 2021-10-25:
// [How to remove emoji code using javascript?](https://stackoverflow.com/questions/10992921/how-to-remove-emoji-code-using-javascript)
// If you need to get rid of complicated emojis,
// you have to remove also additional things like modifiers and etc.
// *#0-9 - are Emoji characters with a text representation by default, per the Unicode Standard.
const ICON_AND_ANY_ISO_DATE_REGEX =
/(?![*#0-9]+)[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]\s*?(?:\d{4}-\d{2}-\d{2})/gu;
// F60. define sTextCleaned:
// #####################################################################
let sTextCleaned = sText;
// F61. define REGEX_SEPARATOR_OF_DVIF: (For better performance)
// #####################################################################
const REGEX_SEPARATOR_OF_DVIF = /::/;
// F63. update sTextCleaned:
// Remove textual fields like the following examples
// Remove DVIF in square brackets: [due:: ] [completion:: ]
// Remove DVIF in round brackets : (due:: ) (completion:: )
// excluding each hidden DVIF : %%(due:: )%% %%(completion:: )%%
// if sTextCleaned contains any string like "::"
// #####################################################################
if (REGEX_SEPARATOR_OF_DVIF.test(sTextCleaned)) {
sTextCleaned = sTextCleaned
//RP63_F21:Clean DVIF_IN_SQUARE_BRACKETS_REGEX
.replace(DVIF_IN_SQUARE_BRACKETS_REGEX, "")
//RP63_F23:Clean DVIF_IN_ROUND_BRACKETS_REGEX
.replace(DVIF_IN_ROUND_BRACKETS_REGEX, "");
}
// F71. update sTextCleaned:
// Remove implicit tags fields
// Remove implicit outlinks fields
// #####################################################################
sTextCleaned = sTextCleaned
//RP71_F31:Clean IMPLICIT_FIELDS_TAGS_REGEX
.replace(IMPLICIT_FIELDS_TAGS_REGEX, "")
//RP71_F33:Clean IMPLICIT_FIELDS_OUTLINKS_REGEX
.replace(IMPLICIT_FIELDS_OUTLINKS_REGEX, "");
// F81. define REGEX_ICONS_OF_TASKS: (For better performance)
// icons: the start/scheduled/due/completion/created dates
// #####################################################################
const REGEX_ICONS_OF_TASKS =
/[\u{1F6EB}β³\u{1F4C5}\u{1F4C6}\u{1F5D3}\u{FE0F}β β]/u;
// F83. update sTextCleaned:
// Remove icon fields like the start/scheduled/due/completion/created dates
// if sTextCleaned contains any icon like REGEX_ICONS_OF_TASKS
// #####################################################################
if (REGEX_ICONS_OF_TASKS.test(sTextCleaned)) {
sTextCleaned = sTextCleaned
// Added by Justdoitcc 2022-11-03
// RP83_F51:Clean ICON_AND_ANY_ISO_DATE_REGEX
.replace(ICON_AND_ANY_ISO_DATE_REGEX, "");
// Remarked by Justdoitcc 2022-11-03
// RP83_F41:Clean START_DATE_REGEX
// .replace(START_DATE_REGEX, "")
// RP83_F43:Clean SCHEDULED_DATE_REGEX
// .replace(SCHEDULED_DATE_REGEX, "")
// RP83_F45:Clean DUE_DATE_REGEX
// .replace(DUE_DATE_REGEX, "")
// RP83_F47:Clean COMPLETION_DATE_REGEX
// .replace(COMPLETION_DATE_REGEX, "")
// RP83_F49:Clean CREATED_DATE_REGEX
// .replace(CREATED_DATE_REGEX, "");
}
// F90. return sTextCleaned:
// #####################################################################
return sTextCleaned;
}
```
Easy peasy. Assuming youβre talking about the icons from Obsidian Tasks, you can use this regex to just remove any text that follows one of the special icons:
t.text.replace(/[π β³π«β«πΌπ½].*$/, '')
Youβve also got a mistake in your code where youβre using a single & when you should be using a double &&. You can read about the difference here.